fix(cli): avoid Windows update check crash - #455
Conversation
`fetch()` can race with `process.exit()` and trigger a libuv assertion on Windows with Node 24 use a nonpersistent `https` connection for the update check
| } | ||
|
|
||
| async function fetchLatestVersion() { | ||
| const agent = new https.Agent({ keepAlive: false }); |
There was a problem hiding this comment.
here's specifically how the crash happens:
- the
fetchbelow completes, but Undici can still have delayed work queued on Node’s worker task scheduler --versionwill then immediately callsprocess.exit(0)- Node starts shutdown and closes the scheduler’s
uv_async_thandle - the queued fetch work races with shutdown and calls
uv_async_send()on that closing handle - Windows libuv hits
assert(!(handle->flags & UV_HANDLE_CLOSING))and aborts with0xC0000409
this is why the version appears before the crash
NO_UPDATE_NOTIFIER=1 avoids fetch(), so there is no delayed work to race with process.exit()
technically it would probably be better to replace some/all of the process.exit(0) in playwright-core to allow for a more graceful shutdown
but this is also arguably correct since there's no need to keep the connection alive any longer
note there is an upstream fix for this nodejs/node#61999 but it has not been put into any release yet and i think this affects as far back as Node 23
Yury Semikhatsky (yury-s)
left a comment
There was a problem hiding this comment.
How does it help with the issue?
| } | ||
|
|
||
| async function fetchLatestVersion() { | ||
| const agent = new https.Agent({ keepAlive: false }); |
There was a problem hiding this comment.
why a new agent?
There was a problem hiding this comment.
i felt this was clearer than relying on the default/global agent implicitly having keepAlive: false
|
closing in favor of the upstream fix |
fetch()can race withprocess.exit()and trigger a libuv assertion on Windows with Node 24use a nonpersistent
httpsconnection for the update checkfixes microsoft/playwright#42402