Skip to content

Keep Node output buffers safe during worker shutdown - #278

Merged
sidmohan0 merged 3 commits into
mainfrom
fix/node-owned-output-buffers
Nov 18, 2026
Merged

sidmohan0 merged 3 commits into
mainfrom
fix/node-owned-output-buffers

Conversation

@sidmohan0

@sidmohan0 sidmohan0 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Native workspace and restore byte outputs can abort Windows Node during shutdown when external Buffer backing-store callbacks outlive their environment (nodejs/node#67417). Copy all six native byte-output paths into JavaScript-owned Buffers, preserve the public byte-array APIs, and wipe the owned export-bundle copy on success and failure.

The installed-package suite repeats its existing full fixture consumer for ten natural exits, including the worker and byte-buffer interactions that reproduced the abort. Each child has a timeout; the ten-exit regression uses no retries, forced GC, sleeps, or forced process exits. The host fixture separately proves no-op contention fails closed and that two candidates prepared from the same head can both save and release after writer contention ends; the state-changing race remains concurrent.

Two independent source reviews found no remaining external Buffer output path. Full workspace/all-features tests, formatting, full clippy with denied warnings, and all ten macOS installed-consumer exits pass; generated public types are unchanged. The final uninstrumented Windows comparison uses the same final fixture workload and all 35 copied conformance helpers for both artifacts, with matching normalized source hashes. Of 100 full consumer natural exits each, the original 8513 artifact had 92 successful exits and 8 shutdown aborts, while the copied-buffer 60a artifact had 100 successful exits and zero failures. Both complete installed setup suites also passed. The earlier comparison independently observed 9 original aborts versus zero fixed failures; production Rust source is unchanged by subsequent test-only commits.

Repeating the full suite also exposed a no-op host assertion that assumed two SQLite writers would both finish within the 250 ms busy timeout. A controlled held-writer probe demonstrates that assumption is unsupported; the original CI failure did not record its outcome and remains unclassified. A subsequent 100-pair observation passed. The corrected fixture preserves both-success/head assertions using two already-prepared candidates with serialized writes, adds an exact storage_busy/no-activation/no-release contention check, and includes outcome diagnostics for unexpected failures.

@sidmohan0
sidmohan0 marked this pull request as ready for review November 18, 2026 16:39
@sidmohan0
sidmohan0 merged commit c5265fa into main Nov 18, 2026
52 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant