mirror of
https://github.com/stablyai/orca.git
synced 2026-09-23 00:02:29 +00:00
Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
isRecoverableRemoteRuntimeConnectionError,
|
|
toRemoteRuntimeClientErrorLike
|
|
} from './remote-runtime-client-error-classification'
|
|
|
|
describe('remote runtime client error classification', () => {
|
|
it.each(['remote_runtime_unavailable', 'runtime_timeout', 'runtime_unavailable', 'reconnecting'])(
|
|
'treats %s as recoverable',
|
|
(code) => {
|
|
expect(isRecoverableRemoteRuntimeConnectionError({ code, message: 'transport failed' })).toBe(
|
|
true
|
|
)
|
|
}
|
|
)
|
|
|
|
it('does not retry authentication or protocol failures', () => {
|
|
expect(
|
|
isRecoverableRemoteRuntimeConnectionError({ code: 'unauthorized', message: 'bad token' })
|
|
).toBe(false)
|
|
expect(
|
|
isRecoverableRemoteRuntimeConnectionError({
|
|
code: 'invalid_runtime_response',
|
|
message: 'bad frame'
|
|
})
|
|
).toBe(false)
|
|
})
|
|
|
|
it.each([
|
|
'Could not connect to the remote Orca runtime.',
|
|
'Remote Orca runtime closed the connection.',
|
|
'Remote Orca runtime connection closed.',
|
|
'Remote Orca runtime is not connected.',
|
|
'Remote runtime subscription closed before it started.'
|
|
])('normalizes unstructured connection failure: %s', (message) => {
|
|
const error = toRemoteRuntimeClientErrorLike(new Error(message))
|
|
expect(isRecoverableRemoteRuntimeConnectionError(error)).toBe(true)
|
|
})
|
|
})
|