fix(common,frontend): make RawRequest context-aware for streaming RPC cancellation#564
Open
ouicate wants to merge 1 commit into
Open
fix(common,frontend): make RawRequest context-aware for streaming RPC cancellation#564ouicate wants to merge 1 commit into
ouicate wants to merge 1 commit into
Conversation
… cancellation Propagate context through common.RawRequest, GetBlock, and getBlockFromRPC so cancelled GetBlockRange streams abort in-flight zcashd JSON-RPC calls instead of holding a goroutine until the HTTP request completes. Production uses a new context-aware HTTP POST client; when btcd adds RawRequestWithContext we can delegate to it directly.
Author
|
Please take a look @nuttycom @LarryRuane @ebfull |
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.
Summary
Addresses the residual goroutine/RPC-slot leak described in GHSA-5h96-xw2v-jxgq after PR #560.
PR #560 fixed the unbounded channel-send leak when a gRPC client disconnects mid-stream, but the producer could still remain blocked inside
getBlockFromRPC→RawRequestfor the duration of an in-flight zcashd JSON-RPC call. This change propagatescontext.Contextthrough the full RPC path so cancelled streams abort in-flight HTTP requests promptly.common.RawRequestto acceptcontext.Contextas its first parameter.ctxthroughgetBlockFromRPC,GetBlock, andGetBlockRange(and gRPC handlers that call them).frontend.NewContextRawRequest, a context-aware HTTP POST JSON-RPC client usinghttp.NewRequestWithContext. Production wiring replaces the previousrpcClient.RawRequestassignment. When btcd landsRawRequestWithContext(btcsuite/btcd#2506), this wrapper can delegate to it directly.ctx.Err()afterhttp.Client.Doerrors instead of retrying.