test(network): fix flaky Test_conn_startSending - #4431
Open
stevenvegt wants to merge 1 commit into
Open
Conversation
The test cancelled the stream before calling disconnect(), racing the receive goroutine (which stores the stream error as close status) against disconnect() cancelling the connection context. Disconnecting first guarantees the context is cancelled before RecvMsg returns, so the receive loop deterministically takes the drop-message path. Master removed this test entirely (#2618); this keeps the goroutine-exit and no-panic coverage instead. Verified with -race -count=100. Assisted-by: AI
Contributor
|
Coverage Impact This PR will not change total coverage. 🚦 See full report on Qlty Cloud »🛟 Help
|
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.

Summary
Test_conn_startSending/disconnect_does_not_panicflaked on CI (seen on #4425): it cancelled the stream before callingdisconnect(), racing the receive goroutine (which stores the stream error as close status,codes.Unknown) againstdisconnect()cancelling the connection context. Whichever won determined whether the finalcodes.OKassertion passed.Reordering to disconnect first guarantees the connection context is cancelled before
RecvMsgreturns, so the receive loop deterministically drops the message without storing a status. This keeps the test's goroutine-exit and no-panic coverage, which master lost when it deleted the test entirely in #2618. Companion PRs re-add the fixed test on master and V6.2.Verified with
go test -race -count=100: 100/100 pass.Assisted-by: AI