mirror of
https://github.com/stablyai/orca.git
synced 2026-11-14 18:07:45 +00:00
fix(remote-runtime): keep node zlib out of browser bundles (#40124)
The renderer's crew follow reconnect scheduler imported the shared-control socket state module, which reaches the Node-only sealed-frame reader and its node:zlib codec. Vite dev throws on that import in the web client, the desktop renderer's crew panel chunk and the component fixtures. Move the reconnect timer function next to the scheduler, its only user.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { scheduleSharedControlReconnect } from './remote-runtime-shared-control-state'
|
||||
import { withReconnectJitter } from '../../reconnect-jitter'
|
||||
|
||||
const ACTIVE_RECONNECT_DELAYS_MS = [250, 500, 1000, 2000, 4000, 8000, 15_000, 30_000]
|
||||
const IDLE_RECONNECT_DELAYS_MS = [...ACTIVE_RECONNECT_DELAYS_MS, 60_000, 120_000, 300_000]
|
||||
@@ -100,3 +100,23 @@ export class SharedControlReconnectScheduler {
|
||||
this.attempt = 0
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleSharedControlReconnect(args: {
|
||||
current: ReturnType<typeof setTimeout> | null
|
||||
intentionallyClosed: boolean
|
||||
reconnectAttempt: number
|
||||
delaysMs: readonly number[]
|
||||
open: () => void
|
||||
}): { timer: ReturnType<typeof setTimeout> | null; reconnectAttempt: number } {
|
||||
if (args.current || args.intentionallyClosed) {
|
||||
return { timer: args.current, reconnectAttempt: args.reconnectAttempt }
|
||||
}
|
||||
const delay = withReconnectJitter(
|
||||
args.delaysMs[Math.min(args.reconnectAttempt, args.delaysMs.length - 1)]
|
||||
)
|
||||
const timer = setTimeout(args.open, delay)
|
||||
if (typeof timer.unref === 'function') {
|
||||
timer.unref()
|
||||
}
|
||||
return { timer, reconnectAttempt: args.reconnectAttempt + 1 }
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import type {
|
||||
SharedControlReadyWaiter
|
||||
} from './remote-runtime-shared-control-types'
|
||||
import { getSubscriptionId, isEndResult } from './remote-runtime-shared-control-protocol'
|
||||
import { withReconnectJitter } from '../../reconnect-jitter'
|
||||
import { tagRuntimeSubscriptionReplayResponse } from '../../runtime-subscription-replay'
|
||||
|
||||
export function rejectSharedControlPendingRequest(
|
||||
@@ -162,23 +161,3 @@ export function closeSharedControlSocketState(args: {
|
||||
// Best-effort cleanup of remote runtime control socket.
|
||||
}
|
||||
}
|
||||
|
||||
export function scheduleSharedControlReconnect(args: {
|
||||
current: ReturnType<typeof setTimeout> | null
|
||||
intentionallyClosed: boolean
|
||||
reconnectAttempt: number
|
||||
delaysMs: readonly number[]
|
||||
open: () => void
|
||||
}): { timer: ReturnType<typeof setTimeout> | null; reconnectAttempt: number } {
|
||||
if (args.current || args.intentionallyClosed) {
|
||||
return { timer: args.current, reconnectAttempt: args.reconnectAttempt }
|
||||
}
|
||||
const delay = withReconnectJitter(
|
||||
args.delaysMs[Math.min(args.reconnectAttempt, args.delaysMs.length - 1)]
|
||||
)
|
||||
const timer = setTimeout(args.open, delay)
|
||||
if (typeof timer.unref === 'function') {
|
||||
timer.unref()
|
||||
}
|
||||
return { timer, reconnectAttempt: args.reconnectAttempt + 1 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user