Description
Running pi update --self on Windows with Node.js v24+ causes a native libuv assertion failure:
Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 94
The update command first prints pi is already up to date (v0.79.4), then crashes with the assertion. The exit code is 127.
Environment
- OS: Windows 11 (Simplified Chinese locale)
- Node.js: v26.3.0
- npm: 11.17.0
- pi version: 0.79.4
- Shell: Git Bash (Git for Windows)
Root Cause
The getLatestPiRelease() function in dist/utils/version-check.js uses the global fetch() API to query https://pi.dev/api/latest-version. On Windows with Node.js v24+, the fetch() implementation has a known libuv race condition where an async handle is closed while still in the UV_HANDLE_CLOSING state, triggering the assertion on process exit.
This is a known issue in the Node.js/libuv ecosystem:
Workaround
Setting the environment variable PI_SKIP_VERSION_CHECK=1 before running the command skips the fetch() call and avoids the crash:
PI_SKIP_VERSION_CHECK=1 pi update --self
This successfully completes the update.
Suggested Fix
Replace fetch() with node:https.request() in getLatestPiRelease() (and any other network calls) to avoid the libuv assertion on Windows, similar to the fix in context-mode PR #84.
The relevant code is in dist/utils/version-check.js:
// Current (causes assertion on Windows + Node 24+)
const response = await fetch(LATEST_VERSION_URL, {
headers: { "User-Agent": getPiUserAgent(currentVersion), accept: "application/json" },
signal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_VERSION_CHECK_TIMEOUT_MS),
});
This should be replaced with node:https or a polyfill that avoids the libuv race condition.
Note
This issue was created by AI (pi with mimo-v2.5). I cannot understand the source code behind the project well.
Description
Running
pi update --selfon Windows with Node.js v24+ causes a native libuv assertion failure:The update command first prints
pi is already up to date (v0.79.4), then crashes with the assertion. The exit code is 127.Environment
Root Cause
The
getLatestPiRelease()function indist/utils/version-check.jsuses the globalfetch()API to queryhttps://pi.dev/api/latest-version. On Windows with Node.js v24+, thefetch()implementation has a known libuv race condition where an async handle is closed while still in the UV_HANDLE_CLOSING state, triggering the assertion on process exit.This is a known issue in the Node.js/libuv ecosystem:
uv_async_sendfetch()withnode:httpsWorkaround
Setting the environment variable
PI_SKIP_VERSION_CHECK=1before running the command skips thefetch()call and avoids the crash:This successfully completes the update.
Suggested Fix
Replace
fetch()withnode:https.request()ingetLatestPiRelease()(and any other network calls) to avoid the libuv assertion on Windows, similar to the fix in context-mode PR #84.The relevant code is in
dist/utils/version-check.js:This should be replaced with
node:httpsor a polyfill that avoids the libuv race condition.Note
This issue was created by AI (pi with mimo-v2.5). I cannot understand the source code behind the project well.