fix: Clear RPC channel for faster shutdown

This commit is contained in:
Alex Alecu
2026-02-25 17:27:11 +02:00
parent 748cee0b02
commit 7182d4c504
+5 -1
View File
@@ -140,10 +140,14 @@ export const rpc = {
await Promise.race([
Instance.disposeAll(),
new Promise((resolve) => {
setTimeout(resolve, 5000)
setTimeout(resolve, 5000).unref()
}),
])
if (server) server.stop(true)
// Clear the Rpc message channel so the worker's event loop can drain and
// exit naturally. Without this, the active onmessage handle keeps the
// worker alive even after all async work is done.
onmessage = null
},
}