W-23459244 fix(node-binding): resolve teardown crash, streaming race, and swallowed read errors#121
Merged
Merged
Conversation
…wed read errors Extracted from the native-bindings work in PR #119 so the fixes to the pre-existing Node binding can be reviewed and merged independently of the new C/Go/Rust bindings. addon.c: - Fix a teardown crash: graal_tear_down_isolate() must run on a thread attached to the isolate. The bootstrap thread from graal_create_isolate() is joined and exits, so its IsolateThread is invalid at cleanup and also leaves a phantom attached thread that blocks teardown forever. Detach the bootstrap thread after create, and attach the cleanup thread before tear down. - Surface the pending JS read-callback exception (message + stack) to stderr and signal an error (bytes_read = -1) instead of silently swallowing it. index.ts: - Fix a streaming race: replace the single resolveChunk slot with a pendingResolves queue so multiple waiting consumers are all woken; the metadata resolution drains the whole queue. - Release consumed pre-buffered input buffers so memory is freed as the async input is drained. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
svacas
approved these changes
Jul 15, 2026
martincousido
approved these changes
Jul 15, 2026
mlischetti
added a commit
that referenced
this pull request
Jul 16, 2026
The native-lib/node/repro and native-lib/python/repro folders are regression guards for the pre-existing Node and Python bindings, covering fixes that already merged to master independently (PR #121 read-callback exception, PR #122 streaming queue backpressure). They are unrelated to the new C/Go/Rust bindings this branch introduces, are not wired into any build/CI, and were intentionally excluded when the Node/Python docs were extracted (PR #126). Remove them so they do not re-land on master with this feature. The C and Go repro folders remain — they exercise the new bindings added here. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mlischetti
added a commit
that referenced
this pull request
Jul 16, 2026
The native-lib/node/repro and native-lib/python/repro folders are regression guards for the pre-existing Node and Python bindings, covering fixes that already merged to master independently (PR #121 read-callback exception, PR #122 streaming queue backpressure). They are unrelated to the new C/Go/Rust bindings this branch introduces, are not wired into any build/CI, and were intentionally excluded when the Node/Python docs were extracted (PR #126). Remove them so they do not re-land on master with this feature. The C and Go repro folders remain — they exercise the new bindings added here. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted from #119 so the fixes to the pre-existing Node binding can be reviewed and merged independently of the new C/Go/Rust bindings.
Changes
native-lib/node/src/addon.cgraal_tear_down_isolate()must be called on a thread attached to the isolate. The bootstrap thread created bygraal_create_isolate()is joined and exits, so itsIsolateThreadis invalid at cleanup— passing it faults, and leaving it attached blocks teardown forever waiting for a dead thread to reach a safepoint. Now the bootstrap thread is detached after create, and the cleanup thread attaches to the isolate to obtain
a valid local
IsolateThreadbefore tearing down.bytes_read = -1) instead of silently clearing it and reporting 0 bytes.native-lib/node/src/index.tsresolveChunkslot with apendingResolvesqueue so every waiting consumer is woken (the single slot dropped all but the last waiter); metadata resolution drains the whole queue.Notes
master; touches only the pre-existing Node binding — no dependency on the new bindings in Native-bindings #119.