fix(capabilities): copy wasm request bodies before send - #225
Merged
Conversation
Node can queue ClientRequest writes before a socket is assigned. Passing a Uint8Array view over wasm memory lets a later memory.grow detach the queued buffer, which can throw from _flushOutput outside the transport retry path. Copy the request body into Node-owned memory for each attempt before writing it. The head is still parsed from the current wasm memory view and response handling is unchanged. This landed on the v0.x release branch in v0.18.1 but was never brought back to main, so main still writes the live wasm view. Refs: #184
bengl
marked this pull request as ready for review
August 31, 2026 17:38
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
gyuheon0h
approved these changes
Aug 31, 2026
gyuheon0h
left a comment
Contributor
There was a problem hiding this comment.
Thanks. We should make sure v0.x's history tracks main's history.
BridgeAR
approved these changes
Aug 31, 2026
BridgeAR
left a comment
Member
There was a problem hiding this comment.
Seems like this is needed, since it is already in a release and we should sync main and the release branch
Overall package sizeSelf size: 31.66 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------|🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Merged
bengl
added a commit
that referenced
this pull request
Aug 31, 2026
v0.x's copy of the wasm request-body test predates the connectionPooling parameter, so replaying it here calls httpRequest with the old nine-argument signature and reads wasm_memory from the wrong slot. Take main's version, which #225 landed with the extra argument. Also take main's Cargo.lock and yarn.lock; replaying the dependency bumps produced only cosmetic dedupe-key differences from the tree those commits were reviewed against.
bengl
added a commit
that referenced
this pull request
Aug 31, 2026
v0.x's copy of the wasm request-body test predates the connectionPooling parameter, so replaying it here calls httpRequest with the old nine-argument signature and reads wasm_memory from the wrong slot. Take main's version, which #225 landed with the extra argument. Also take main's Cargo.lock and yarn.lock; replaying the dependency bumps produced only cosmetic dedupe-key differences from the tree those commits were reviewed against.
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.
What does this PR do?
Restores the WASM HTTP transport request-body copy on
main.httpRequestnow writes a Node-ownedBuffercopy of the body for each attempt instead of a liveUint8Arrayview over wasm memory, adapted to the current signature that carriesconnectionPooling.Adds a regression test (
http_transport request body lifetime) that grows the wasm memory afterhttpRequestreturns but before Node flushes its queued write.Motivation
This fix shipped on the
v0.xrelease branch in v0.18.1 (#184, commit5c2e31d) but was never forward-ported tomain, somainregressed to the original behavior. Node can queueClientRequestwrites before a socket is assigned; a latermemory.grow()detaches the backingArrayBufferandClientRequest._flushOutputthrows asynchronously, outside thereq.write()try/catch retry path.Found while preparing the v0.19.0 release, which takes
mainontov0.x— without this, 0.19.0 would reintroduce a bug fixed in 0.18.1.How to test the change?
In a worktree at this branch:
node --test test/http_transport.js— 21 pass, 0 failhttp_transport.jschange stashed — 1 fail:TypeError: Cannot perform Construct on a detached ArrayBuffer, from the new testnpx eslint .— cleanNot run locally: the root native suite (
yarn test), which needs a full cargo prebuild; CI covers it.