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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
