You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DO_NOT_TRACK=1 crashes the CLI on Windows (libuv assertion, exit 0xC0000409) since 2.14.0 #356
Since bailian-cli 2.14.0, setting DO_NOT_TRACK=1 in the environment makes every real command crash with a libuv assertion. Embedders that run the CLI headlessly (background quota readers, schedulers) commonly set this variable, so 2.14.0 breaks them.
Reproduction
Windows 10.0.26300 x64, node v24.10.0, bailian-cli 2.14.0 (npm global). Spawn via execFile(node.exe, [bailian.mjs, ...]) with cwd: os.tmpdir(), windowsHide: true, DO_NOT_TRACK=1:
Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76
exit code 3221226505 (0xC0000409). --version survives because it never reaches the telemetry path; every command that emits telemetry crashes deterministically, so this looks like a close-vs-async-send race in the telemetry submission path (libuv uv_async_send on a closing handle) rather than a network failure.
2.13.0 did not have this behavior (background readers worked with the same environment).
Expected
DO_NOT_TRACK=1 should suppress telemetry without affecting the command's result or stability
node -v, npm -v, npm list -g bailian-cli, and whether PATH resolves to Bun bl.exe or the npm bailian.mjs entry
Whether anything else is special in the parent process (Electron, custom BAILIAN_CONFIG_DIR, proxy, AV, etc.)
Until we have a reliable repro, we won’t land a speculative fix for this issue alone. Downstream can keep the workaround of not forcing DO_NOT_TRACK=1 for background quota reads.
We tracked this down to an upstream Node.js Windows bug (nodejs/node#56645 / nodejs/node#58091), fixed in nodejs/node#61999 and backported to Node.js v24.20.0 (commit 05ec9c4771), combined with the forced process.exit() introduced in bailian-cli@2.13.0 by #348. Upgrading local Node.js from v24.10.0 to v24.22.3 completely eliminates the crash.
Root Cause & Corrections to the Initial Report
Underlying Node.js bug (v23.x and v24.0–v24.19 on Windows):WorkerThreadsTaskRunner::DelayedTaskScheduler::Stop() closes uv_async_t flush_tasks_ without a shutdown guard, racing against V8 background worker threads (PostDelayedTask -> uv_async_send) during process.exit() teardown and hitting Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76 (0xC0000409).
Correction 1 (version): The regression started in v2.13.0, not v2.14.0 (an earlier npm pack test of 2.13.0 exited 1 early on missing subpackages; full isolated installs confirmed 2.12.0 = exit 0, 2.13.0 = crash, 2.14.0 = crash).
Correction 2 (interactive runs): Direct PowerShell runs do also crash when DO_NOT_TRACK=1 is set (EXIT=-1073740791). Interactive runs only passed previously because DO_NOT_TRACK was unset in the shell.
Why DO_NOT_TRACK=1 Toggles It & Why Repro Varies Across Windows Machines
Why DO_NOT_TRACK=1 acts as the switch: Without DO_NOT_TRACK=1, await flushTelemetry(1000) waits ~250–300 ms for the gm.mmstat.com request before process.exit(0), inadvertently acting as a grace delay past the < 50 ms post-fetch() race window (on v24.10.0, a 0 ms or 10 ms delay before process.exit(0) crashed, while 50 ms+ passed 5/5). With DO_NOT_TRACK=1, telemetry short-circuits in 0 ms, so process.exit(0) executes ~0–1 ms after globalThis.fetch() completes.
Why 6/6 passed on your Windows + v24.10.0 host: As documented in nodejs/node#56645, this race is highly sensitive to Windows build and thread scheduling (for example, reproducing 100% on Windows 11 Build 10.0.26300 while passing on some Windows Server 2025 / other Windows builds on the exact same Node version).
(b) Standalone pure-Node.js repros (no bailian-cli or credentials needed):
// Official nodejs/node#61999 regression test (no internet required)require('http').createServer((_,res)=>{res.writeHead(302,{Location: '/'});res.end();}).listen(0,'127.0.0.1',asyncfunction(){try{awaitfetch(`http://127.0.0.1:${this.address().port}/`);}catch{}process.exit(0);});
Stdout prints the complete valid JSON payload, and stderr emits only:
Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76
Exit code: 3221226505 (0xC0000409 / -1073740791).
Environment
OS: Windows 10.0.26300 x64 (16 CPUs)
Before upgrade:node v24.10.0, npm 11.6.1
After upgrade:node v24.22.3, npm 11.19.1
CLI install / entry: npm global (node .../bailian-cli/dist/bailian.mjs, not Bun bl.exe); npm list -g bailian-cli is pinned at 2.12.0, while 2.13.0 and 2.14.0 were tested from clean isolated npm install directories.
Parent / config specifics
Reproduces under plain node (execFile) and direct PowerShell (not Electron-specific).
Default ~/.bailian/config.json (no custom BAILIAN_CONFIG_DIR), authenticated via AK/SK (access_key_id + access_key_secret, no console access_token), so console call executes two sequential fetch() calls (modelstudio.cn-beijing.aliyuncs.com -> bailian-cs.console.aliyun.com).
PR #348 added process.exit() specifically to avoid Bun's ~50s keep-alive socket linger on Windows. If runToExit only forces process.exit() under Bun (process.versions.bun) and lets Node.js exit naturally via process.exitCode (like v2.12.0 did), Windows users still on Node v23.x or v24.0–v24.19 would also be protected without regressing Bun. Otherwise, noting Node >= 24.20.0 (or v22.x) on Windows is sufficient and this issue can be closed.
Activity
hopelynd commentedon Dec 1, 2026
Thanks for the report. We tried to reproduce this on Windows with the same setup described here and in token-monitor#1734 / PR #1753:
node …/dist/bailian.mjs)execFile(node, [bailian.mjs, …], { cwd: os.tmpdir(), windowsHide: true })DO_NOT_TRACK=1+NO_UPDATE_NOTIFIER=1console call --api zeldaHttp.apikeyMgr./tokenplan/personal/api/v2/usage --data '{}' --console-region cn-beijing --console-site domestic --output jsonResult: 6/6 runs exited 0 and returned valid JSON. No
UV_HANDLE_CLOSING/0xC0000409.Interactive runs also do not crash (consistent with your note).
So we cannot reproduce a deterministic crash under the publicly described conditions. Marking this as needinfo.
If you still hit it, please share:
execFileoptions + env)node -v,npm -v,npm list -g bailian-cli, and whether PATH resolves to Bunbl.exeor the npmbailian.mjsentryBAILIAN_CONFIG_DIR, proxy, AV, etc.)Until we have a reliable repro, we won’t land a speculative fix for this issue alone. Downstream can keep the workaround of not forcing
DO_NOT_TRACK=1for background quota reads.mamaruo commentedon Dec 1, 2026
We tracked this down to an upstream Node.js Windows bug (nodejs/node#56645 / nodejs/node#58091), fixed in nodejs/node#61999 and backported to Node.js
v24.20.0(commit05ec9c4771), combined with the forcedprocess.exit()introduced inbailian-cli@2.13.0by #348. Upgrading local Node.js fromv24.10.0tov24.22.3completely eliminates the crash.Root Cause & Corrections to the Initial Report
v23.xandv24.0–v24.19on Windows):WorkerThreadsTaskRunner::DelayedTaskScheduler::Stop()closesuv_async_t flush_tasks_without a shutdown guard, racing against V8 background worker threads (PostDelayedTask->uv_async_send) duringprocess.exit()teardown and hittingAssertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76(0xC0000409).bailian-cliside trigger (v2.13.0, PR fix(runtime): flush tracked stdout/stderr before exit after run #348): Before2.13.0,bailian.mjsended with.run()and let the event loop drain naturally (v2.12.0exits 0 even withDO_NOT_TRACK=1). PR fix(runtime): flush tracked stdout/stderr before exit after run #348 (fix/exit-after-run) wrapped execution inrunToExit()and unconditionally calledprocess.exit(process.exitCode ?? 0)afterawait flushOutputs(null).v2.13.0, notv2.14.0(an earliernpm packtest of2.13.0exited 1 early on missing subpackages; full isolated installs confirmed2.12.0= exit 0,2.13.0= crash,2.14.0= crash).DO_NOT_TRACK=1is set (EXIT=-1073740791). Interactive runs only passed previously becauseDO_NOT_TRACKwas unset in the shell.Why
DO_NOT_TRACK=1Toggles It & Why Repro Varies Across Windows MachinesDO_NOT_TRACK=1acts as the switch: WithoutDO_NOT_TRACK=1,await flushTelemetry(1000)waits ~250–300 ms for thegm.mmstat.comrequest beforeprocess.exit(0), inadvertently acting as a grace delay past the< 50 mspost-fetch()race window (onv24.10.0, a 0 ms or 10 ms delay beforeprocess.exit(0)crashed, while 50 ms+ passed 5/5). WithDO_NOT_TRACK=1, telemetry short-circuits in 0 ms, soprocess.exit(0)executes ~0–1 ms afterglobalThis.fetch()completes.v24.10.0host: As documented innodejs/node#56645, this race is highly sensitive to Windows build and thread scheduling (for example, reproducing 100% on Windows 11 Build10.0.26300while passing on some Windows Server 2025 / other Windows builds on the exact same Node version).Requested Details
Minimal repro scripts
(a) Exact
bailian.mjsexecFilerepro (matchedcliEnvironment+DO_NOT_TRACK=1):(b) Standalone pure-Node.js repros (no
bailian-clior credentials needed):Full stderr of a failing run
Stdout prints the complete valid JSON payload, and stderr emits only:
Exit code:
3221226505(0xC0000409/-1073740791).Environment
10.0.26300x64 (16 CPUs)node v24.10.0,npm 11.6.1node v24.22.3,npm 11.19.1node .../bailian-cli/dist/bailian.mjs, not Bunbl.exe);npm list -g bailian-cliis pinned at2.12.0, while2.13.0and2.14.0were tested from clean isolatednpm installdirectories.Parent / config specifics
node(execFile) and direct PowerShell (not Electron-specific).~/.bailian/config.json(no customBAILIAN_CONFIG_DIR), authenticated via AK/SK (access_key_id+access_key_secret, no consoleaccess_token), soconsole callexecutes two sequentialfetch()calls (modelstudio.cn-beijing.aliyuncs.com->bailian-cs.console.aliyun.com).Before / After Verification
v24.10.0v24.22.3(includes#61999)bailian-cli@2.12.0+DO_NOT_TRACK=10bailian-cli@2.13.0+DO_NOT_TRACK=10xC0000409,async.c:76)0, valid JSON, empty stderrbailian-cli@2.14.0+DO_NOT_TRACK=1(stripped env)0xC0000409,async.c:76)0, valid JSON, empty stderrnodejs/node#61999localhost 302 loopasync.c:76)0fetch('https://bailian-cs.console.aliyun.com/') + process.exit(0)async.c:76)0Suggestion
PR #348 added
process.exit()specifically to avoid Bun's ~50s keep-alive socket linger on Windows. IfrunToExitonly forcesprocess.exit()under Bun (process.versions.bun) and lets Node.js exit naturally viaprocess.exitCode(likev2.12.0did), Windows users still on Nodev23.xorv24.0–v24.19would also be protected without regressing Bun. Otherwise, notingNode >= 24.20.0(orv22.x) on Windows is sufficient and this issue can be closed.本回复使用 Gemini 4 总结