Skip to content

cli: fix iceSetup.stop() in-flight refresh race, fetchRelay timeout, and refreshInMs clamping - #439

Open
Pybsama wants to merge 1 commit into
Nehanth:mainfrom
Pybsama:fix/cli-relay-stop-race-and-timeout
Open

Pybsama wants to merge 1 commit into
Nehanth:mainfrom
Pybsama:fix/cli-relay-stop-race-and-timeout

Conversation

@Pybsama

@Pybsama Pybsama commented Dec 4, 2026

Copy link
Copy Markdown

Summary

  • cli/lib/relay.js (iceSetup):
    • Track a stopped flag and an active AbortController for each periodic refresh() so calling stop() while a refresh fetch is in flight aborts the request immediately, skips mutating config.iceServers if the fetch resolves late, and never reschedules another timer.
  • cli/lib/relay.js (fetchRelay):
    • Support an optional external signal (propagating aborts and cleaning up the listener in finally) and race both the fetch and got.json() body read against the timeout/abort promise (catching internal rejections) so a stalled response body or non-aborting fetchImpl always resolves to null within timeoutMs.
  • cli/lib/relay.js (refreshInMs):
    • Default non-positive or non-finite TTLs (such as negative values, NaN, or Infinity) to 3600s and clamp the resulting delay to 2147483647ms (the max signed 32-bit setTimeout delay) so oversized or non-finite TTLs never trigger Node's 1ms timeout overflow loop.
  • Tests (cli/test/relay_test.mjs): Add 3 regression tests covering the stop() in-flight race, stalled json()/non-aborting fetch/external abort signal, and refreshInMs edge cases (all 3 failed before the fix).

Verification

  • node --check cli/lib/relay.js cli/test/relay_test.mjs: passed.
  • node --test cli/test/room_test.mjs cli/test/relay_test.mjs: 17/17 passed (8/8 in relay_test.mjs).
  • npm run test:packages: 213 passed, 6 skipped, 0 failed.
  • npm run test:runtime: passed.

@Pybsama
Pybsama requested a review from Nehanth as a code owner December 4, 2026 05:37
@vercel

vercel Bot commented Dec 4, 2026

Copy link
Copy Markdown

@Pybsama is attempting to deploy a commit to the nehanth's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant