Skip to content

fix(common,frontend): make RawRequest context-aware for streaming RPC cancellation#564

Open
ouicate wants to merge 1 commit into
zcash:masterfrom
ouicate:fix/context-aware-rawrequest-getblockrange
Open

fix(common,frontend): make RawRequest context-aware for streaming RPC cancellation#564
ouicate wants to merge 1 commit into
zcash:masterfrom
ouicate:fix/context-aware-rawrequest-getblockrange

Conversation

@ouicate

@ouicate ouicate commented Jun 10, 2026

Copy link
Copy Markdown

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 getBlockFromRPCRawRequest for the duration of an in-flight zcashd JSON-RPC call. This change propagates context.Context through the full RPC path so cancelled streams abort in-flight HTTP requests promptly.

  • Change common.RawRequest to accept context.Context as its first parameter.
  • Thread ctx through getBlockFromRPC, GetBlock, and GetBlockRange (and gRPC handlers that call them).
  • Add frontend.NewContextRawRequest, a context-aware HTTP POST JSON-RPC client using http.NewRequestWithContext. Production wiring replaces the previous rpcClient.RawRequest assignment. When btcd lands RawRequestWithContext (btcsuite/btcd#2506), this wrapper can delegate to it directly.
  • Return immediately on ctx.Err() after http.Client.Do errors instead of retrying.

… 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.
@ouicate

ouicate commented Jun 20, 2026

Copy link
Copy Markdown
Author

Please take a look @nuttycom @LarryRuane @ebfull

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