Skip to content

Conversation

@leighmcculloch
Copy link
Member

What

  • Add context.Context parameter to all NetworkClient interface methods (SubmitTransaction, GetAccountDetails, SimulateTransaction)
  • Propagate context from HTTP handlers through Minion to network client calls
  • Update RPC client to use the passed context for timeouts instead of creating new context.Background() internally
  • Horizon client accepts context but ignores it (underlying client doesn't support context propagation)

Why

Request cancellation and timeout propagation require context to flow from HTTP handlers through to network backend calls. Without this, if a client disconnects mid-request, the HTTP call to the network backend continues unnecessarily. This also enables distributed tracing spans to link across service boundaries.

Closes #22

Known limitations

N/A

@leighmcculloch leighmcculloch marked this pull request as ready for review January 20, 2026 12:40
Copilot AI review requested due to automatic review settings January 20, 2026 12:40
@leighmcculloch leighmcculloch enabled auto-merge (squash) January 20, 2026 12:40
@leighmcculloch leighmcculloch requested a review from a team January 20, 2026 12:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds context propagation to all NetworkClient interface methods to enable proper request cancellation, timeout propagation, and distributed tracing. The context flows from HTTP request handlers through the Bot and Minion layers down to the network backend calls (RPC/Horizon clients).

Changes:

  • Added context.Context parameter to all NetworkClient interface methods (SubmitTransaction, GetAccountDetails, SimulateTransaction)
  • Updated RPC client to use passed context instead of creating new context.Background() internally
  • Propagated context through Minion helper functions and transaction building methods
  • Horizon client accepts context parameter but documents it as unused (underlying client limitation)

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/network_client.go Added context.Context parameter to NetworkClient interface methods
internal/rpcnetworkclient/client.go Updated to use passed context, compose timeouts properly, removed TODO
internal/rpcnetworkclient/client_test.go Updated tests to pass context.Background()
internal/horizonnetworkclient/client.go Added context parameter with documentation that it's not used
internal/horizonnetworkclient/client_test.go Updated tests to pass context.Background()
internal/minion.go Propagated context through Run(), helper functions, and network calls
internal/minion_test.go Updated mock function signatures to include context parameter
internal/account.go Updated RefreshSequenceNumber to accept and propagate context
internal/friendbot_test.go Updated mock function signatures to include context parameter
init_friendbot.go Added context.Background() for initialization network calls
friendbot_api_test.go Updated mock implementations and tests to use context
friendbot_api_rpc_integration_test.go Updated integration tests to pass context.Background()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Propagate Request Context to Network Backends

2 participants