mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-15 07:36:50 +03:00
Fix Windows libuv abort in concept-seed after a successful roll (#526)
* Fix Windows libuv abort in concept-seed after a successful roll process.exit() with a live fetch keep-alive socket trips libuv's UV_HANDLE_CLOSING assertion on Windows (nodejs/node#56645), aborting the CLI with 0xC0000409 after complete output on the successful-roll path. Destroy the global undici dispatcher before the explicit exit so no socket is left to race; the hard exit stays, keeping the no-linger guarantee on blackholed networks. Fixes #504 Prepared with AI assistance (Cursor agent) under maintainer direction. * Add regression test for the successful-API dispatcher teardown The suite covered local rolls and the unreachable-API fallback but never a successful roll, the one path where a pooled keep-alive socket exists at exit (issue #504). Serve a real /api/roll from a local server and assert the CLI destroys fetch's global dispatcher before its explicit exit. Verified to fail without the fix. Prepared with AI assistance (Cursor agent) under maintainer direction. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -692,6 +692,13 @@ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.ur
|
||||
process.exitCode = 1;
|
||||
}
|
||||
// A raced-out fetch may still hold a socket; exit explicitly so the CLI
|
||||
// never lingers on a dead network path after output is written.
|
||||
// never lingers on a dead network path after output is written. Destroy
|
||||
// fetch's global undici dispatcher first: process.exit() with a live
|
||||
// keep-alive socket trips a libuv assertion on Windows and aborts the
|
||||
// process after a successful roll (nodejs/node#56645).
|
||||
const dispatcher = globalThis[Symbol.for('undici.globalDispatcher.1')];
|
||||
if (dispatcher && typeof dispatcher.destroy === 'function') {
|
||||
try { await dispatcher.destroy(); } catch { /* exit regardless */ }
|
||||
}
|
||||
process.exit(process.exitCode ?? 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user