qwen-code/packages/node-repl/src
Shaojin Wen 249ab50d84
fix(node-repl): let the kernel exit promptly on shutdown (#15160)
* fix(node-repl): let the kernel exit promptly on shutdown

The kernel reads its input pipe through a file stream, and a pending
read on that pipe keeps process.exit() from completing until the pipe
reaches EOF. Since the manager began waiting 2.5 s for a graceful exit
before signalling, every reset and disposal cost about 3 seconds and
ended in SIGTERM, which also slowed the node-repl suite from ~35 s to
~3.8 min in CI.

End the pipe right after the shutdown frame so the kernel can exit as
soon as its cleanup finishes.

* fix(node-repl): stop session processes when the kernel exits on its own

Ending the kernel's input pipe lets it exit within milliseconds, so the
group signals that used to reach processes the session started without
detaching were no longer sent: they kept running after reset, disposal
and a cancellation timeout.

When the kernel exits on its own, signal its process group the way the
signalled shutdown did: SIGTERM, then SIGKILL if anything is still in the
group after 500 ms. The group keeps its ID while any member lives, and a
kernel that was already gone before termination began is left alone.

Tests start a child from session code that holds a socket to the test,
so its exit is seen even when nothing reaps it, and cover reset,
disposal, a timed-out cancellation barrier and a child that ignores
SIGTERM. The idle-kernel test now checks that no signal reaches a
running kernel rather than that no signal is sent at all.

* fix(node-repl): stop leftover session processes after a SIGTERM exit too

The process group stop ran only when the kernel exited within the first
grace period. A kernel whose own cleanup outlasts it (a slow Computer
Use disposal, say) exits during the SIGTERM wait instead, so neither the
group stop nor the SIGKILL ran, and a session process that ignores
SIGTERM kept running. Before the pipe was closed that kernel could not
finish exiting, so the old path always reached SIGKILL.

Run the group stop whenever the kernel exits before the hard stop. A
test blocks Computer Use disposal past the grace period and checks that
a SIGTERM-ignoring child is still stopped.

* test(node-repl): pin the SIGTERM step of the leftover-process sweep

The slow-cleanup case was named for a kernel that exits on SIGTERM, but
the kernel ignores SIGTERM once shutdown has started; it exits when the
fixture's cleanup ends. Rename it and assert the group got SIGTERM while
the kernel was still running, so a kernel that exits in the first wait
no longer passes for this path.

Add a case whose session process handles SIGTERM by writing a marker and
exiting, so replacing the SIGTERM-then-SIGKILL sweep with a bare SIGKILL
fails a test.
2026-10-23 17:14:58 +00:00
..
desktop-relay feat(cua): streamline computer use and port native reliability fixes (#14846) 2026-10-21 14:03:31 +08:00
fixtures/napi refactor(node-repl)!: deliver the persistent Node REPL as a standalone MCP server (#9499) 2026-08-23 14:20:39 +00:00
runtime feat(cua): streamline computer use and port native reliability fixes (#14846) 2026-10-21 14:03:31 +08:00
cell-bindings.ts fix(cua): address tool failures and efficiency in OSWorld runs (#11683) 2026-09-13 09:12:47 +00:00
cell-transform.test.ts fix(cua): address tool failures and efficiency in OSWorld runs (#11683) 2026-09-13 09:12:47 +00:00
cell-transform.ts fix(cua): address tool failures and efficiency in OSWorld runs (#11683) 2026-09-13 09:12:47 +00:00
debug-log.test.ts refactor(node-repl)!: deliver the persistent Node REPL as a standalone MCP server (#9499) 2026-08-23 14:20:39 +00:00
debug-log.ts refactor(node-repl)!: deliver the persistent Node REPL as a standalone MCP server (#9499) 2026-08-23 14:20:39 +00:00
index.ts feat(cua): streamline computer use and port native reliability fixes (#14846) 2026-10-21 14:03:31 +08:00
kernel-manager.test.ts fix(node-repl): let the kernel exit promptly on shutdown (#15160) 2026-10-23 17:14:58 +00:00
kernel-manager.ts fix(node-repl): let the kernel exit promptly on shutdown (#15160) 2026-10-23 17:14:58 +00:00
mcp-server.test.ts feat(cua): streamline computer use and port native reliability fixes (#14846) 2026-10-21 14:03:31 +08:00
mcp-server.ts feat(cua): streamline computer use and port native reliability fixes (#14846) 2026-10-21 14:03:31 +08:00
node-repl.lines.test.ts feat(cua): streamline computer use and port native reliability fixes (#14846) 2026-10-21 14:03:31 +08:00
node-repl.napi.test.ts feat(cua): streamline computer use and port native reliability fixes (#14846) 2026-10-21 14:03:31 +08:00
node-repl.reload.test.ts feat(cua): streamline computer use and port native reliability fixes (#14846) 2026-10-21 14:03:31 +08:00
node-repl.scale.test.ts feat(cua): streamline computer use and port native reliability fixes (#14846) 2026-10-21 14:03:31 +08:00
node-repl.semantics.test.ts feat(cua): streamline computer use and port native reliability fixes (#14846) 2026-10-21 14:03:31 +08:00
output-adapter.test.ts feat(browser-use): add Chrome Native Messaging relay (#11242) 2026-09-18 05:50:24 +00:00
output-adapter.ts feat(browser-use): add Chrome Native Messaging relay (#11242) 2026-09-18 05:50:24 +00:00
protocol.test.ts refactor(node-repl)!: deliver the persistent Node REPL as a standalone MCP server (#9499) 2026-08-23 14:20:39 +00:00
protocol.ts feat(cua): streamline computer use and port native reliability fixes (#14846) 2026-10-21 14:03:31 +08:00
security-policy.test.ts refactor(node-repl)!: deliver the persistent Node REPL as a standalone MCP server (#9499) 2026-08-23 14:20:39 +00:00
security-policy.ts refactor(node-repl)!: deliver the persistent Node REPL as a standalone MCP server (#9499) 2026-08-23 14:20:39 +00:00
tokenizer.test.ts refactor(node-repl)!: deliver the persistent Node REPL as a standalone MCP server (#9499) 2026-08-23 14:20:39 +00:00
tokenizer.ts refactor(node-repl)!: deliver the persistent Node REPL as a standalone MCP server (#9499) 2026-08-23 14:20:39 +00:00
win-path.test.ts refactor(node-repl)!: deliver the persistent Node REPL as a standalone MCP server (#9499) 2026-08-23 14:20:39 +00:00
win-path.ts refactor(node-repl)!: deliver the persistent Node REPL as a standalone MCP server (#9499) 2026-08-23 14:20:39 +00:00