Restore Windows exit delay and setBlocking workarounds#138
Closed
silverwind wants to merge 3 commits into
Closed
Conversation
Aborting the prewarms isn't enough — the keep-alive socket pool still has idle handles that race during natural shutdown on Windows + Node 24 (nodejs/node#56645). Closing the global dispatcher drains the pool cleanly, eliminating the race. Node exposes the global dispatcher via Symbol.for("undici.globalDispatcher.1"); this is the same mechanism undici itself uses to share it with the runtime. Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
Owner
Author
|
Switching to a simpler workaround approach — see follow-up. |
The Symbol-based dispatcher.close workaround relied on a private Node API and didn't reliably fix the Node 24 Windows flake. Restoring the straightforward 100ms-on-Windows delay and the stdio setBlocking workaround is honest about the upstream Node bug and avoids reaching into internals. Refs nodejs/node#56645 Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
Refs nodejs/node#56645 Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
Owner
Author
|
Reverted #137 on master instead. See nodejs/node#56645 — this can only be fixed in Node itself. |
mickey-mikey
added a commit
to mickey-mikey/ai-inference
that referenced
this pull request
May 24, 2026
…rash On Windows, the explicit process.exit() calls in run() abort with Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76 when the openai SDK's undici-based HTTP/2 connection pool is still tearing down the TLS socket to models.github.ai. This is the upstream Node bug tracked at nodejs/node#56645 — Node calls uv_async_send() on an async handle after uv_close(), which libuv asserts against. The upstream fix (nodejs/node#61999) has been stalled in review since January 2025, and no released Node version contains it yet. Reproduces 100% of the time against models.github.ai on Windows Node 24 with the openai SDK; passes 100% with a brief setTimeout before exit. Same workaround already shipped by astral-sh/setup-uv (#880, 100ms) and silverwind/updates (actions#138, 200ms). Extract a `safeExit(code)` helper that yields for 100ms on Windows only before calling process.exit; Linux and macOS take the original code path with no added latency. Refs: - nodejs/node#56645 - astral-sh/setup-uv#880 - silverwind/updates#138
mickey-mikey
added a commit
to mickey-mikey/ai-inference
that referenced
this pull request
May 24, 2026
…rash On Windows, the explicit process.exit() calls in run() abort with Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76 when the openai SDK's undici-based HTTP/2 connection pool is still tearing down the TLS socket to models.github.ai. This is the upstream Node bug tracked at nodejs/node#56645 — Node calls uv_async_send() on an async handle after uv_close(), which libuv asserts against. The upstream fix (nodejs/node#61999) has been stalled in review since January 2025, and no released Node version contains it yet. Reproduces 100% of the time against models.github.ai on Windows Node 24 with the openai SDK; passes 100% with a brief setTimeout before exit. Same workaround already shipped by astral-sh/setup-uv (#880, 100ms) and silverwind/updates (actions#138, 200ms). Extract a `safeExit(code)` helper that yields for 100ms on Windows only before calling process.exit; Linux and macOS take the original code path with no added latency. Refs: - nodejs/node#56645 - astral-sh/setup-uv#880 - silverwind/updates#138
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Symbol-based
dispatcher.close()approach relied on a private Node API and didn't reliably fix the Node 24 Windows flake. Going back to the straightforward 200ms-on-Windows delay (up from the original 50ms — community minimum is 100ms+, doubled for headroom) and the stdiosetBlockingworkaround — honest about the upstream Node bug, no reaching into internals.Refs nodejs/node#56645
This PR was written with the help of Claude Opus 4.7