Skip to content

test: fix the intermittent PortAllocatorConfigIntegrationTest failures - #256

Merged
devopvoid merged 1 commit into
devopvoid:mainfrom
SendableMetatype:fix/ice-trickle-test-race
Aug 12, 2026
Merged

test: fix the intermittent PortAllocatorConfigIntegrationTest failures#256
devopvoid merged 1 commit into
devopvoid:mainfrom
SendableMetatype:fix/ice-trickle-test-race

Conversation

@SendableMetatype

Copy link
Copy Markdown
Contributor

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.

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.
@devopvoid
devopvoid merged commit e315944 into devopvoid:main Aug 12, 2026
7 checks passed
@SendableMetatype
SendableMetatype deleted the fix/ice-trickle-test-race branch August 12, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants