Repository navigation
In review
Labels
scope-ciRelated to ci/cd pipelinescope-decentralizedFor the decentralized settingscope-discojsRelated to Disco.jstype-bugSomething isn't working
Description
Problem
discojs/src/client/decentralized/peer.spec.ts intermittently fails in CI (verify / test / discojs) with Vitest's default 5s timeout on peer > transfers GPT-sized payload with byte-for-byte reassembly:
Error: Test timed out in 5000ms.
❯ discojs/src/client/decentralized/peer.spec.ts:82:3
Example failure: https://github.com/epfml/disco/actions/runs/45438603494 (on PR #1290, unrelated to decentralized peer code).
Root causes observed
- Loopback UDP packet drops trigger SCTP retransmission stalls under load:
Peer.flush()(discojs/src/client/decentralized/peer.ts) bursts up toHIGH_WATER_MARK = 1 MiB(16 × 64 KiBchunks) in a synchronous loop into@roamhq/wrtc, exceeding Linux's default UDP receive buffer (net.core.rmem_default = 212992bytes, ~208 KiB). Even locally on an idle machine, ~10% of 10 MB transfers spike from ~90 ms to ~705 ms with a ~400 ms inter-chunk gap (usrsctpT3-rtx recovery). On CI runners running 30 Vitest test files in parallel (includinggpt.spec.ts,hellaswag.spec.ts, andonnx.spec.ts), passing runs ofpeer.spec.tsalready take ~812–1363 ms, and repeated SCTP retransmissions with backoff push the test past 5,000 ms. - Test timeout is shorter than
Peer's own drain timeout:peer.spec.tsuses Vitest's default5_000ms timeout, which is half ofPeer.drain()'s defaultMAX_DRAIN_TIME = 10_000ms (peer.ts:16). For comparison,peer_pool.spec.tssets{ timeout: 10_000 }. - External STUN servers queried on every unit test:
Peer(peer.ts:76-85) hardcodes public Google/Twilio STUN servers, causing unnecessary external ICE candidate gathering on everybeforeEach. - Silent hangs on peer errors/disconnects:
peer.spec.tsdoes not listen topeer1/peer2"error"or"close"events, anddrain()returns silently if the channel closes, soawait receivedPromisehangs until Vitest's timeout instead of failing fast with the actual error.
Proposed fix
- Set an explicit timeout in
discojs/src/client/decentralized/peer.spec.ts(e.g.,{ timeout: 20_000 }, aboveMAX_DRAIN_TIME) and attach fail-fast"error"/ unexpected"close"handlers in the test setup. - Allow configuring
iceServers(or an optionalRTCConfiguration) onPeer, and passiceServers: []in unit tests so loopback tests do not depend on external STUN servers. - Evaluate whether
HIGH_WATER_MARK/ send pacing inPeer.flush()should be tuned for Node/loopback vs. high-RTT WAN throughput (locally,128 KiBeliminated the 10 MB stalls:0/20spikes,max = 112 ms, vs.1 MiBfor WAN BDP).
Metadata
Metadata
Assignees
Labels
scope-ciRelated to ci/cd pipelinescope-decentralizedFor the decentralized settingscope-discojsRelated to Disco.jstype-bugSomething isn't working
Activity