From 48ccdd5212ea2a744a75efb32232b9104214bd76 Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Mon, 9 Nov 2026 04:34:49 +0000 Subject: [PATCH] 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. --- ...remote-runtime-shared-control-reconnect.ts | 22 ++++++++++++++++++- .../remote-runtime-shared-control-state.ts | 21 ------------------ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/shared/remote-runtime/control/remote-runtime-shared-control-reconnect.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-reconnect.ts index 18cc05d08c2..f998c492a40 100644 --- a/src/shared/remote-runtime/control/remote-runtime-shared-control-reconnect.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-reconnect.ts @@ -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 | null + intentionallyClosed: boolean + reconnectAttempt: number + delaysMs: readonly number[] + open: () => void +}): { timer: ReturnType | 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 } +} diff --git a/src/shared/remote-runtime/control/remote-runtime-shared-control-state.ts b/src/shared/remote-runtime/control/remote-runtime-shared-control-state.ts index 533278f3af7..f1cc6ecd1e5 100644 --- a/src/shared/remote-runtime/control/remote-runtime-shared-control-state.ts +++ b/src/shared/remote-runtime/control/remote-runtime-shared-control-state.ts @@ -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 | null - intentionallyClosed: boolean - reconnectAttempt: number - delaysMs: readonly number[] - open: () => void -}): { timer: ReturnType | 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 } -}