Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
为什么
internal/bootstrap的TestRuntimeOpenStartClose偶尔报「关闭 HTTP 服务:context deadline exceeded」。关闭超时时抓了 goroutine 快照:没有任何请求在处理,只剩测试客户端空闲池里的一条连接,服务端那头还在等它的第一个请求。Go 的 HTTP 客户端在等连接时可能会多拨一条,用不上就放进空闲池;服务端要等这种从没收到请求的连接满 5 秒才把它当空闲连接关掉,而测试给的关闭时限正好是 5 秒。
这是测试客户端留下的连接,不是运行时关闭有问题。
改了什么
只改测试:调用
runtime.Close之前,先http.DefaultClient.CloseIdleConnections()。验证
同一份测试在 #408 的分支上失败得最频繁,所以在那里对比:
main 和 #407 的分支各跑 10 次、12 次,修之前也都没失败过,所以 main 上没有复现这个失败;这里的依据是上面的连接快照和 #408 上的对比。
🤖 Generated with Claude Code