qmd/scripts
Tobi Lutke c5f4217a6f
fix(cli): exit naturally so node-llama-cpp's beforeExit fires
The libggml-metal static destructor asserts on a non-empty residency-set
collection during __cxa_finalize_ranges, dumping a multi-kB GGML backtrace
after successful output (ggml-org/llama.cpp#22593, one-line fix open as
PR #22595). The assertion only trips when process.exit() skips Node's
beforeExit hook — which is exactly the hook node-llama-cpp registers to
auto-dispose its native handles.

Primary fix: finishSuccessfulCliCommand now sets process.exitCode = 0
and returns instead of calling process.exit(0). The event loop drains,
beforeExit fires, native Metal resources tear down in order, and the
process exits cleanly even without the workaround env var.

Defense-in-depth retained: bin/qmd and scripts/test-all.mjs still export
GGML_METAL_NO_RESIDENCY=1 on darwin for error paths and tests that
terminate via process.exit(). Opt back in with QMD_METAL_KEEP_RESIDENCY=1.

Also: correct upstream issue refs (was #17869 → now #22593/#22595).
Add scripts/repro-metal-rsets-crash.mjs minimal reproduction.
2026-05-28 17:23:31 -07:00
..
build.mjs chore: strengthen package test task 2026-05-19 14:27:38 -04:00
check-package-grammars.mjs Fix AST grammar packaging for Bun installs 2026-05-09 18:13:58 +00:00
extract-changelog.sh feat: compile to JS for npm, release system, full changelog 2026-02-16 08:42:32 -04:00
install-hooks.sh feat: compile to JS for npm, release system, full changelog 2026-02-16 08:42:32 -04:00
package-smoke.mjs chore: strengthen package test task 2026-05-19 14:27:38 -04:00
pre-push fix: pre-push hook writes to stderr, no interactive prompts 2026-02-16 11:53:52 -04:00
release.sh Make release script portable 2026-05-19 23:08:30 +00:00
repro-metal-rsets-crash.mjs fix(cli): exit naturally so node-llama-cpp's beforeExit fires 2026-05-28 17:23:31 -07:00
test-all.mjs fix(cli): exit naturally so node-llama-cpp's beforeExit fires 2026-05-28 17:23:31 -07:00