diff --git a/client/transport/stdio.go b/client/transport/stdio.go index c36dc2d37..7602e2446 100644 --- a/client/transport/stdio.go +++ b/client/transport/stdio.go @@ -307,6 +307,13 @@ func (c *Stdio) SendRequest( ctx context.Context, request JSONRPCRequest, ) (*JSONRPCResponse, error) { + // Check if context is already canceled before doing any work + select { + case <-ctx.Done(): + return nil, ctx.Err() + default: + } + if c.stdin == nil { return nil, fmt.Errorf("stdio client not started") }