Repository navigation
fix(vendor): forward the gRPC-web trailer frame to tonic - #28
Open
danielgorgonha wants to merge 5 commits into
Open
danielgorgonha wants to merge 5 commits into
danielgorgonha wants to merge 5 commits into
Conversation
…wasm-client The response body can now be fed from in-memory chunks, so the tests run natively, without a browser: `ResponseBody::new` delegates to a private `from_body_stream` (no change in behaviour), and a `cfg(test)` `BodyStream::from_chunks` builds the stream. Eight of the tests fail on this commit: the trailer frame is parsed but never handed to tonic, so a status sent in the body trailer is lost. Co-Authored-By: Claude <noreply@anthropic.com>
tonic-web-wasm-client 0.8.0 parsed the trailer frame, stored it in a field nothing read, and ended the body as soon as it saw the trailer flag. tonic never got the trailers, and with HTTP 200 and no trailers it reports success, so a status sent in the body trailer (an error after some messages, or after a unary message) was lost. The body now yields the parsed trailers as a trailers frame, once, after the last data frame. It only counts as finished once the trailer frame has been read in full, so a trailer split across chunks is read and a stream that ends inside the trailer frame is MalformedResponse instead of a clean end. The first part is the response_body.rs change of upstream 0f232d33 (devashishdxt/tonic-web-wasm-client#90, released in 0.9.1). Co-Authored-By: Claude <noreply@anthropic.com>
…ob for the vendored tests trailers.patch applies on top of trailers-only.patch and reproduces src/ from crates.io 0.8.0, apart from the test files: it carries their two cfg(test) hooks but not src/response_body/. The vendored crate is excluded from the workspace, so a separate job runs its tests against the workspace lock. Co-Authored-By: Claude <noreply@anthropic.com>
Their browser OHTTP proof had already fixed it in its own patch, not only found it. Co-Authored-By: Claude <noreply@anthropic.com>
1 task done
They found the lost trailer status, reproduced it and fixed it first in their browser OHTTP proof (https://github.com/Crackdevs/zcash-browser-ohttp-proof). Co-authored-by: Crackdevs <info@crackdevs.org> Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Nov 17, 2026
This branch has not been deployed
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.
Changes
tonic-web-wasm-client0.8.0 parsed the trailer frame and then dropped it, so tonic never saw the trailers, and tonic 0.14.3 (the locked version) treats HTTP 200 with no trailers as success. A stream that failed part-way looked complete, a unary call that returned a message followed by an error status looked successful, and an error sent with no message before it became an empty successful stream.zcash-mainnet.chainsafe.devanswersGetBlockfor a height past the tip with HTTP 200, nogrpc-statusheader, and a body that is a single trailer frame withgrpc-status: 11. Today a unary call on that body fails withInternal: Missing response message.instead of the server's status, and the same body read as a server stream is an empty success. With this change both getOutOfRange: GetBlock: block 999999999 is newer than the latest block. The body, captured on 2026-11-15, is a test fixture here.MalformedResponseinstead of a clean end. Unchanged: trailers-only responses (status in the HTTP headers, empty body), and a body that ends with no trailer frame (stillMalformedResponse).src/response_body.rschange of Check and forward any trailers on stream end. devashishdxt/tonic-web-wasm-client#90 (upstream 0f232d33, released in 0.9.1). The split-trailer case is upstream issue "missing grpc-status trailer" error when the end of the response arrives in two pieces devashishdxt/tonic-web-wasm-client#97, and the open upstream PR fix: read the whole trailers frame when it is split across chunks devashishdxt/tonic-web-wasm-client#112 makes the same change to the end-of-body check (onlyDonecounts as finished); it is not merged. This workspace cannot take 0.9.x: every 0.9.x release depends onwasm-streams0.5 or later, which requireswasm-bindgen >= 0.2.108, against the=0.2.100pin kept for the MetaMask Snap.VENDORED.mddescribes both local fixes.trailers.patchapplies on top oftrailers-only.patchand reproducessrc/from crates.io 0.8.0, apart from the test files (the patch carries only their twocfg(test)hooks).vendored-tonic-web-wasm-client: the crate is excluded from the workspace, so--allnever built its tests.Unknown: protocol error: missing grpc-status trailer, ...before this change and succeeds after it. So without this fix, acargo updateof tonic breaks every call that has a body.Behaviour that changes for apps: an error that a server sends in the body trailer now fails the call, where before it was silently dropped. In a normal sync we saw no difference: a read-only sync of the last 200 blocks, with a new account, completed to the tip both before and after this change, against
https://zjs.zec.rocks/testnet(testnet),https://zcash-mainnet.chainsafe.dev(mainnet) andhttps://zjs.zec.rocks/mainnet(the web wallet's mainnet proxy), in headless Chromium with the threaded build.Other behaviour changes: a trailer block that does not parse now fails with
HeaderParsingErrorwhether it arrives in one chunk or split (before, the split case ended silently). Body trailers now reach tonic, and tonic 0.14.3 panics on an invalidgrpc-status-details-bin(Status::from_header_mapdecodes it withexpect): a server could already trigger that through the HTTP headers, and now it can also do so through the body trailer.Known and not changed:
grpc-status: 0in the headers together with an error in a body trailer still reports success; repeated trailer keys keep only the last value (upstream #103); bytes after the trailer frame are ignored; base64 (grpc-web-text) mode is not used here; like a data frame, a trailer frame is buffered until its announced length has arrived.The problem was found, reproduced and first fixed by @Crackdevs in their browser OHTTP proof, built on this branch (https://github.com/Crackdevs/zcash-browser-ohttp-proof): their
wallet.patchalready makes the decoder pass the trailers to tonic and require a complete trailer frame. That repository has no licence file, so none of their code is used here; this patch was written separately, from the upstream change named above. If they open their own pull request, we will close this one in its favour. The analysis and the patch were prepared with an AI assistant and reviewed by us.Tests
15 tests (14 new). The first commit adds the tests, a
cfg(test)constructor that feeds the body from in-memory chunks, and moves the body ofResponseBody::newinto a privatefrom_body_stream(no change in behaviour). On that commit, 8 fail (trailers never yielded, split trailers, end inside the trailer frame, tonic streaming and unary calls, the captured body). With the fix, all 15 pass. The guards (trailers-only empty body, trailers-only with a truncated body, data with no trailer, cut inside a data frame, captured successful body, nothing after the trailers) pass on both commits.Issues
main. I can retarget tomainonce Feat/nu7 portable keys #27 lands, or fold this into Feat/nu7 portable keys #27, whichever you prefer.🤖 Generated with Claude Code