AlexStocks commented on code in PR #3832:
URL: https://github.com/apache/dubbo-go/pull/3832#discussion_r4612510437
##########
remoting/getty/getty_client.go:
##########
@@ -267,6 +277,11 @@ func (c *Client) RequestContext(ctx context.Context,
request *remoting.Request,
case <-response.Done:
err = response.Err
case <-ctx.Done():
+ // Drop the pending waiter, but keep the shared session. Caller
+ // cancellation is not a transport failure; a later request may
+ // reuse this connection. The read-timeout branch still closes
+ // the session because that path can no longer trust it.
+
remoting.RemoveCancelledPendingResponse(remoting.SequenceType(request.ID))
Review Comment:
[P2] 这一行替换没有任何测试钉子,回归时会静默失效
`RequestContext` 的 `ctx.Done()` 分支从 `RemovePendingResponse` 换成
`RemoveCancelledPendingResponse`,是「迟到响应降级为 Debug」的唯一生产入口;但本 PR 新增的 4 个用例都直接调用
`remoting.RemoveCancelledPendingResponse` / `markPendingCancelled`,没有一条经过
`Client.RequestContext`。
实测(head c708c035,go1.25.0 darwin/amd64,一次性副本):把本行改回
`remoting.RemovePendingResponse(remoting.SequenceType(request.ID))` 后,`go test
-count=1 -run TestHandleCanceledRequestLogsDebug ./remoting/` 仍然
`ok`(0.059s)。即这一行退回旧实现后,`exchange_test.go` 里 4 个新用例全绿,真实取消路径会重新产生 ERROR 日志而无人发现。
建议补一条从 `getty.Client.RequestContext` 进入的用例(可复用 `getty_server_test.go` 里已有的真实
server/session 搭建):注册 pending → 在发送成功后取消 ctx → 注入迟到 `Response` 并 `Handle()` →
断言 `recordLogger` 的 errors 为空、debugs 非空。若搭建 session 成本过高,也可把该分支里「标记取消 +
移除」收敛为一个可直接单测的函数,再由本行调用,让测试至少覆盖到这条分支。
--
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]