test: fix the intermittent PortAllocatorConfigIntegrationTest failures - #256
Merged
devopvoid merged 1 commit intoAug 12, 2026
Merged
Conversation
Candidate gathering starts inside createOffer and createAnswer via setLocalDescription, so the test forwarded candidates to a peer that often had no remote description yet. The native stack rejects such candidates and nothing retries them, so when both directions lost all candidates during the exchange the connection never formed and the test burned its whole timeout. This was the common cause of the intermittent iceCandidatesRespectPortAllocatorConfig failures on CI. The peers now buffer outgoing candidates and deliver them after both descriptions are set, forwarding directly from then on. The candidate list also became a CopyOnWriteArrayList since it is written on the signaling thread and read on the test thread.
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.
iceCandidatesRespectPortAllocatorConfig fails intermittently on CI with "Caller failed to connect in time" and passes when run again (this week: the first runs on #245 and #248, the post merge run on main, and the current run on #249). The cause is a race in the test, not in the library. Candidate gathering starts inside createOffer and createAnswer through their setLocalDescription call, and the test forwards every candidate to the remote peer straight from onIceCandidate, while the test thread has not yet applied the corresponding remote descriptions. A candidate that arrives before its receiver has a remote description is rejected by the native stack and never retried. ICE usually connects anyway, because one surviving direction rescues the other through peer reflexive candidates; when both directions lose every candidate, no pair ever forms and the test burns the entire timeout. That matches the observed failures, which exhaust the full wait rather than connecting slowly. Loaded CI runners widen the race window, which is why this fires on CI and rarely on developer machines.
The peers now buffer outgoing candidates; the test delivers them once both descriptions are applied and forwards directly from then on, so no candidate can reach a peer that cannot accept it. The candidates list also became a CopyOnWriteArrayList, since it is written on the signaling thread and read on the test thread. I have not verified this with a CI run, and a green run would not prove much for an intermittent failure anyway; the fix follows from the mechanism above, so the real confirmation is the failures no longer recurring. Test only, no library code changes. Independent of #249, which raises this test's timeout; the two merge cleanly in either order.