ReviewOS

home-lang/home

fix(runtime): block napi_reference_unref in experimental finalizers

#572
Closed chris opened this 9 days ago ·
9 days ago

Follow-up to #459 and #66 from the pinned Bun Node-API corpus at 4982b91e3702094330f3be3883354c52b8c01323.

Exact failing test:

  • napi > napi_reference_unref is blocked from finalizers in experimental modules

The self-contained wrapper expects the experimental finalizer process to reject the forbidden napi_reference_unref call and exit successfully after validating that contract. Home currently exits 1. The regular-module companion test passes, so the remaining boundary is specifically experimental finalizer GC access enforcement.

Acceptance:

  • Match Node/Bun's experimental finalizer restriction and status behavior.
  • Keep napi_reference_unref can be called from finalizers in regular modules green.
  • Add or retain a focused native regression that does not depend on node-gyp downloads.
  • Re-run the pinned napi/napi.test.ts corpus file.
9 days ago

Resolved by 436b7b574439dbc19c4d6a7d7d8f59facf7522dc (fix(runtime): complete Node-API finalizer lifecycle).

The remaining mismatch was specific to --expose-gc: assigning the native Bun.gc host function directly meant a zero-argument global.gc() could keep the preceding Node-API host-call result alive in the caller frame. Home now installs a real JavaScript gc() wrapper that calls the native collector with a material true argument. It is installed under the JSC API lock in both the upstream Run path and Home's native VM path.

Home's temporary crash-handler bridge now also emits Bun's stable main-thread panic prefix and aborts immediately, avoiding debug symbolizer stalls in deliberate fatal-path tests.

Verification:

  • Exact test_experimental_with_timeout.js: passes; napi_reference_unref aborts from an experimental finalizer reached through zero-argument global.gc().
  • Full pinned Bun N-API file: 99 passed, 0 failed, 0 unsupported, 0 todo.
  • Runtime aggregate: 57 passed, 0 failed.
  • Native runtime units: 1,816 passed, 19 skipped, 0 failed.

The vendored napi/napi.test.ts remains byte-for-byte identical to pinned Bun.

Sign in to comment on this issue.