Skip to content

Drop process.exit() to let Node shut down naturally#137

Merged
silverwind merged 2 commits into
masterfrom
drop-exit-and-windows-workaround
May 10, 2026
Merged

Drop process.exit() to let Node shut down naturally#137
silverwind merged 2 commits into
masterfrom
drop-exit-and-windows-workaround

Conversation

@silverwind

Copy link
Copy Markdown
Owner

The 50ms Windows workaround for nodejs/node#56645 was insufficient on Node 26 — the libuv assertion fires from uv_async_send after uv_close, which the explicit exit() precipitates. Setting process.exitCode and letting the event loop drain avoids the racy shutdown path entirely.

Removes the setBlocking() workaround on stdout/stderr too — it was only needed because exit() doesn't flush async writes; natural shutdown does.

Re-enables Node 24 and 26 on Windows in CI.


This PR was written with the help of Claude Opus 4.7

silverwind and others added 2 commits May 10, 2026 23:58
The 50ms Windows workaround for nodejs/node#56645 was insufficient on
Node 26: the libuv assertion fires from uv_async_send after uv_close,
which the explicit exit() precipitates. Setting process.exitCode and
letting the event loop drain avoids the racy shutdown path entirely.

Removes the setBlocking() workaround on stdout/stderr too — it was only
needed because exit() doesn't flush async writes; natural shutdown does.

Re-enables Node 24 and 26 on Windows in CI.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
The fire-and-forget prewarm fetches could still be in flight when main()
returns, racing with natural shutdown and triggering the libuv assertion
on Node 24 Windows. Tracking them with an AbortController and awaiting
their settlement in end() ensures clean shutdown.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@silverwind silverwind merged commit eea63c9 into master May 10, 2026
60 checks passed
@silverwind silverwind deleted the drop-exit-and-windows-workaround branch May 10, 2026 22:21
silverwind added a commit that referenced this pull request May 10, 2026
silverwind added a commit that referenced this pull request May 11, 2026
* update deps (silverwind)
* Revert "Drop `process.exit()` to let Node shut down naturally (#137)" (silverwind)
* Drop `process.exit()` to let Node shut down naturally (#137) (silverwind)
* Exclude Node 26 on windows-latest (silverwind)
* Update vitest-config-silverwind to 11.3.3, add Node 26 to CI (silverwind)
* update deps (silverwind)
* Minor perf and simplification cleanups (silverwind)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant