fix(remote-runtime): recover terminals after network loss (#9774)

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-07-21 15:18:45 -07:00
committed by GitHub
co-authored by Brennan Benson
parent e986a7ba1a
commit 54c1ec5e7a
44 changed files with 2776 additions and 258 deletions
@@ -0,0 +1,43 @@
export type RemoteRuntimeClientErrorLike = { code?: string; message: string }
const RECOVERABLE_CODES = new Set([
'remote_runtime_unavailable',
'runtime_timeout',
'runtime_unavailable',
'reconnecting',
'timeout'
])
const RECOVERABLE_MESSAGE_FRAGMENTS = [
'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 connection closed',
'remote runtime subscription closed before it started',
'remote terminal stream is not connected',
'timed out waiting for the remote orca runtime'
]
export function isRecoverableRemoteRuntimeConnectionError(
error: RemoteRuntimeClientErrorLike
): boolean {
if (error.code && RECOVERABLE_CODES.has(error.code)) {
return true
}
const message = error.message.toLowerCase()
return RECOVERABLE_MESSAGE_FRAGMENTS.some((fragment) => message.includes(fragment))
}
export function toRemoteRuntimeClientErrorLike(error: unknown): RemoteRuntimeClientErrorLike {
if (error && typeof error === 'object') {
const candidate = error as { code?: unknown; message?: unknown }
if (typeof candidate.message === 'string') {
return {
...(typeof candidate.code === 'string' ? { code: candidate.code } : {}),
message: candidate.message
}
}
}
return { message: String(error) }
}