From e3acd9f8bc64080163e3cf8962c74296a1be47e5 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Fri, 23 Oct 2026 21:15:06 -0700 Subject: [PATCH] fix(execution): close retired remote sandbox workers with a normal closure The pool retires idle and recycled workers by killing them. For a remote worker that closed the socket with no code, which the client reports as 1005 and logs as a warning, so every routine idle retirement looked like a failed connection. Close app-initiated retirements with 1000; closes the app didn't ask for still warn. --- apps/sim/lib/execution/isolated-vm-remote.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/sim/lib/execution/isolated-vm-remote.ts b/apps/sim/lib/execution/isolated-vm-remote.ts index b43d0366faf..9ababaf2716 100644 --- a/apps/sim/lib/execution/isolated-vm-remote.ts +++ b/apps/sim/lib/execution/isolated-vm-remote.ts @@ -67,10 +67,10 @@ export function connectRemoteWorker(options: RemoteWorkerOptions): IsolatedVMWor } /** Exits on a later tick, as a killed child does, so the pool never re-enters its own cleanup. */ - const terminate = (reason: string) => { + const terminate = (reason: string, closeCode?: number) => { exitReason ??= reason try { - socket.close() + socket.close(closeCode) } catch {} setImmediate(() => emitExit(reason)) } @@ -120,7 +120,8 @@ export function connectRemoteWorker(options: RemoteWorkerOptions): IsolatedVMWor return true }, kill() { - terminate('Remote isolated-vm worker closed by the app') + // A normal closure, so the pool retiring an idle or recycled worker isn't logged as a failure. + terminate('Remote isolated-vm worker closed by the app', 1000) return true }, on(event: 'message' | 'exit', listener: (message: unknown) => void) {