ReviewOS

home-lang/home

Native runtime: isolate process exit dispatch per VM and restore worker fixture exit guards

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

Follow-up to #66 and #461. BunProcess.cpp dispatchExitInternal uses a process-wide static bool. The first worker exits and suppresses exit listeners for all later workers and the main process; this also races across threads. Actual exact Node FileHandle worker tests exited zero without executing common.mustCall assertions or tmpdir cleanup, so those results are provisional. Fix in progress: authoritative one-shot flag in each Home VirtualMachine ExitHandler, accessed through an exported native gate without modifying the external Process class ABI or trusting writable process._exiting. Guard before user callbacks for reentrancy. Guarded native-process-exit-dispatch.test.mjs covers sequential workers, main/worker explicit exit, reentrant exit, changed exitCode, beforeExit rescheduling, and a real missing common.mustCall after a worker exits. Existing binary fails the sequential-worker scenario. Rebuild and exact worker fixture reruns required before completion. #462 tracks separate MessagePort close events.

9 days ago

The per-VM gate build passed all12 steps and all13 existing/native message regression files still pass. Additional review found worker natural-exit listener exceptions are swallowed because web_worker.zig sets is_shutting_down before vm.onExit; uncaughtException returns early in that state. The bounded follow-up removes that premature assignment (vm.onExit sets it after dispatch, before cleanup) and adds throwing exit-handler coverage. Final rebuild and worker fixture reruns follow; zero exit alone is not accepted as proof.

9 days ago

Implemented and verified in local commit32ddb4171 (Chris Breuer sole author/committer, no coauthors): per-VM native exit guard, user exit callbacks before shutdown suppression, worker-aware fatal error reporting/termination, and termination-aware beforeExit draining. All8 native subprocess scenarios pass, including throwing exit guards, real common.mustNotCall assertion, beforeExit error with a referenced timer, nested handler failure(code7), explicit/natural/reentrant exits, and positive/negative common.mustCall controls. Exact FileHandle fixture now genuinely removes its temp file on exit. All14 native regression files pass; final build and unchanged rebuild12/12. Full worker parity remains open in #461/#462 and #66. Commit publication status will be recorded on #66.

9 days ago

Publication gate is now satisfied. 32ddb4171 is reachable on current main and contains the per-VM exit guard plus worker-aware exit/error ordering described and verified above. The bounded issue no longer depends on an unpublished local commit. Broader worker lifecycle remains under #66. Closing as completed.

Sign in to comment on this issue.