Repository navigation
fix(metadata, protocol, proxy): preserve request context across RPC paths - #3579
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #3579 +/- ##
===========================================
+ Coverage 46.76% 55.17% +8.40%
===========================================
Files 295 474 +179
Lines 17172 36878 +19706
===========================================
+ Hits 8031 20347 +12316
- Misses 8287 14886 +6599
- Partials 854 1645 +791 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR addresses context propagation bugs across several Dubbo-Go RPC entrypoints/bridges (metadata RPC, REST, JSON-RPC, proxy, and RPCInvocation), ensuring cancellations, deadlines, tracing values, and context-based attachments are preserved rather than being dropped via context.Background().
Changes:
- Add request
context.Contextstorage/accessors oninvocation.RPCInvocationand preserve it when building attachment contexts. - Propagate inbound request contexts through REST and JSON-RPC server handlers into both
Invoker.Invoke(ctx, ...)and the createdRPCInvocation. - Thread context into metadata RPC calls via a new
GetMetadataFromRpcWithContextAPI and add regression tests for the above paths.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| proxy/proxy.go | Sets the invocation context on generated RPCInvocation instances in proxy calls. |
| protocol/rest/server/rest_server.go | Uses the raw HTTP request context for invocation and invocation context; adds nil raw-request guard. |
| protocol/rest/server/rest_server_test.go | Adds regression test asserting REST request context propagates into invoker + invocation. |
| protocol/jsonrpc/server.go | Derives ctx from *http.Request (including tracing extraction) and sets it on RPCInvocation. |
| protocol/jsonrpc/server_test.go | Adds test ensuring request context values/cancellation are preserved by contextFromRequest. |
| protocol/invocation/rpcinvocation.go | Introduces RPCInvocation context storage (Context/SetContext) and uses it when creating attachment contexts. |
| protocol/invocation/rpcinvocation_test.go | Adds test ensuring GetAttachmentAsContext() preserves request context values. |
| metadata/client.go | Adds GetMetadataFromRpcWithContext and forwards ctx into invoker invocation + RPCInvocation. |
| metadata/client_test.go | Adds tests ensuring metadata RPC invocation receives the caller context. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@Alanxtl 请帮我重新rerun一下ci 谢谢 owo |
…text-propagation # Conflicts: # protocol/jsonrpc/server.go
Picked up JAVA_TOOL_OPTIONS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false
/opt/hostedtoolcache/CodeQL/2.26.2/x64/codeql/java/tools/autobuild.sh
Picked up JAVA_TOOL_OPTIONS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false
ERROR: Could not detect a suitable build command for the source checkout.
Error: We were unable to automatically build your code. Please replace the call to the autobuild action with your custom build steps. Encountered a fatal error while running "/opt/hostedtoolcache/CodeQL/2.26.2/x64/codeql/java/tools/autobuild.sh". Exit code was 1 and last log line was: ERROR: Could not detect a suitable build command for the source checkout. See the logs for more details.仓库 CodeQL workflow 的自动语言探测不稳定:这次意外识别到了嵌套的 Java benchmark 项目,然后 Java autobuild 失败。上一次同版本 CodeQL 只识别到 Go,因此通过了。 |
|



Description
Fixes #3557.
Preserve request context across metadata RPC, REST, JSON-RPC, proxy, and
RPCInvocationflows. This prevents cancellation, deadlines, tracing values, and context attachments from being lost when a newcontext.Background()is created.Added regression tests for metadata v1/v2, REST, JSON-RPC, and invocation context propagation.
修复 metadata RPC、REST、JSON-RPC、proxy 和
RPCInvocation链路中的 context 丢失问题,确保取消信号、超时、deadline、tracing 信息及 context attachment 能够继续传递。新增 metadata v1/v2、REST、JSON-RPC 和 invocation context 传播的回归测试。
Checklist
develop