You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "AlexStocks (via GitHub)" <gi...@apache.org> on 2026/07/28 02:48:37 UTC

[I] [Bug] Request context dropped via context.Background() in metadata/proxy/triple/jsonrpc/rest paths (cancellation/timeout not respected) (P1) [dubbo-go]

AlexStocks opened a new issue, #3557:
URL: https://github.com/apache/dubbo-go/issues/3557

   ## Summary
   
   Multiple code paths construct a fresh `context.Background()` (or `context.WithCancel(context.Background())`) instead of propagating the incoming request context, so cancellation, deadlines, and timeouts set by the caller are silently dropped. The result is hung RPCs that cannot be aborted, leaked resources under load, and broken framework-level timeout/attachment handling.
   
   ## Affected locations
   
   | File:Line | Code | Why it's wrong |
   |-----------|------|----------------|
   | `metadata/client.go:77, 92, 97, 171` | `ctx := context.Background()` for metadata RPC calls | The code's own comment admits *"ctx is not yet forwarded; cancellation not respected"*. Cancellation never reaches the invoker. |
   | `proxy/proxy.go:150` | `invCtx := context.Background()` (default) | Only uses the real ctx when the user passes context as the first method argument; otherwise framework-level timeout/attachment are lost. |
   | `protocol/triple/triple_invoker.go:306` | `ctx, cancel := context.WithCancel(context.Background())` in `startHealthWatch` | Health-check goroutine is decoupled from the upstream invoker lifecycle and cannot be cancelled by the caller. |
   | `protocol/jsonrpc/server.go:165` | `ctx := context.Background()` when handling a request | Request context (with deadlines/values) is discarded. |
   | `protocol/rest/server/rest_server.go:113` | `ctx := context.Background()` | Same as above. |
   | `protocol/invocation/rpcinvocation.go:247` | `context.Background()` when merging attachment | Attachment merge loses the request context. |
   
   ## Impact
   
   - Caller cancellation / deadline has no effect on these sub-RPCs → connections and goroutines accumulate under failure or load.
   - Framework-level timeout and attachment propagation are silently broken for the affected protocols.
   
   ## Suggested fix
   
   Propagate the incoming `context.Context` instead of `context.Background()`. Where none exists yet (metadata client), thread a ctx parameter through and default to the request ctx, not `Background()`.
   
   ## Verification
   
   `GOTOOLCHAIN=local go vet ./...` on develop tip (HEAD 53d81d17) reports **zero** default-analyzer warnings (see #3552). `go vet` does not cover context-propagation correctness — manual review / `noctx` linter is needed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] Request context dropped via context.Background() in metadata/proxy/triple/jsonrpc/rest paths (cancellation/timeout not respected) (P1) [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on issue #3557:
URL: https://github.com/apache/dubbo-go/issues/3557#issuecomment-5364545913

   close via #3579


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [Bug] Request context dropped via context.Background() in metadata/proxy/triple/jsonrpc/rest paths (cancellation/timeout not respected) (P1) [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl closed issue #3557: [Bug] Request context dropped via context.Background() in metadata/proxy/triple/jsonrpc/rest paths (cancellation/timeout not respected) (P1)
URL: https://github.com/apache/dubbo-go/issues/3557


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org