SIGN IN SIGN UP
oven-sh / bun UNCLAIMED

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one

0 0 150 Rust

install: gate the exit-callback cache teardown to the main thread (#31376)

The package manager registers an exit callback that tears down its
workspace package.json cache so LeakSanitizer does not report it as
still reachable at exit. Exit callbacks run on whichever thread drives
process exit, but the cache's per-entry arenas are created by and owned
by the main thread, so running that teardown from another thread (e.g.
the HTTP client thread when CA-file validation fails) is unsound and can
abort the process instead of exiting with code 1.

This change registers the callback only in ASAN builds (it is wasted
work otherwise) and makes the callback a no-op when invoked off the main
thread, letting the OS reclaim the memory on that path.

Adds a test that runs `bun install --cafile /does/not/exist` in a
workspace project, which populates the cache on the main thread before
the HTTP thread fails initialization and drives exit; it asserts the
error message and exit code 1. Because the underlying failure is
timing-dependent, the unfixed binary does not fail this test on every
run, but the test pins the exact configuration that was intermittently
dumping core in CI ("certificate authority > non-existent --cafile" on
the alpine x64 lane). The existing cafile tests continue to pass.
J
Jarred Sumner committed
29f1f7c5d5b7b30830210eadc5a53cb5a87d4b72
Parent: e262c99
Committed by GitHub <noreply@github.com> on 5/26/2026, 12:04:06 AM