Skip to content

Commit 511a064

Browse files
authored
fix(execution): close retired remote sandbox workers with a normal closure (#9358)
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.
1 parent 0753608 commit 511a064

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎apps/sim/lib/execution/isolated-vm-remote.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ export function connectRemoteWorker(options: RemoteWorkerOptions): IsolatedVMWor
6767
}
6868

6969
/** Exits on a later tick, as a killed child does, so the pool never re-enters its own cleanup. */
70-
const terminate = (reason: string) => {
70+
const terminate = (reason: string, closeCode?: number) => {
7171
exitReason ??= reason
7272
try {
73-
socket.close()
73+
socket.close(closeCode)
7474
} catch {}
7575
setImmediate(() => emitExit(reason))
7676
}
@@ -120,7 +120,8 @@ export function connectRemoteWorker(options: RemoteWorkerOptions): IsolatedVMWor
120120
return true
121121
},
122122
kill() {
123-
terminate('Remote isolated-vm worker closed by the app')
123+
// A normal closure, so the pool retiring an idle or recycled worker isn't logged as a failure.
124+
terminate('Remote isolated-vm worker closed by the app', 1000)
124125
return true
125126
},
126127
on(event: 'message' | 'exit', listener: (message: unknown) => void) {

0 commit comments

Comments
 (0)