Skip to content

Honor options.fetch on /generate-ice-servers request#396

Closed
thanipro wants to merge 2 commits intocloudflare:mainfrom
tranqbay:tranqbay/iceservers-bearer-auth
Closed

Honor options.fetch on /generate-ice-servers request#396
thanipro wants to merge 2 commits intocloudflare:mainfrom
tranqbay:tranqbay/iceservers-bearer-auth

Conversation

@thanipro
Copy link
Copy Markdown

@thanipro thanipro commented May 2, 2026

Tiny one-line fix in makePeerConnectionSessionCombo. The sessions/new request honors options.fetch via fetchImpl, but the /generate-ice-servers request doesn't — they should match.

If a consumer wires up a custom fetch via PartyTracksConfig.fetch (to inject auth headers, add tracing, retry on transient failures, sign requests, etc.), it currently silently doesn't apply to the iceServers GET. So whatever that fetch was doing — Authorization headers, request signing, anything — gets dropped on that one request.

     iceServers: options.iceServers
       ? of(options.iceServers)
       : fromFetch(`${options.prefix}/generate-ice-servers`, {
+          fetchImpl: options.fetch,
           selector: (res) =>
             res
               .json()
               .then(
                 (body) => (body as { iceServers: RTCIceServer[] }).iceServers
               )
         })

No behavior change for consumers that don't pass a custom fetch — fetchImpl defaults to the global fetch in fromFetch.ts:35.

Changeset added (patch). Happy to add a unit test if you want one — let me know your preferred shape since the existing tests in tests/ don't currently exercise the fetchImpl plumbing.


Disclosure: drafted with help from an AI coding assistant (Claude), reviewed and tested locally before opening.

`makePeerConnectionSessionCombo`'s `iceServers` arm of the forkJoin
wasn't passing `fetchImpl: options.fetch`, so even when a consumer
configured a custom `fetch` on `PartyTracksConfig` (e.g. to inject
an Authorization header), the GET fell back to the global `fetch`
with no consumer headers.

The matching `sessionId` arm two lines above already passed
`fetchImpl: options.fetch`. This brings the iceServers arm in line.

No behavior change for consumers without a custom fetch —
`fetchImpl` defaults to global fetch via fromFetch.ts:35.

Caught when `tranqbay/call` ran with an authenticated
`/partytracks/*` proxy: POST /sessions/new succeeded, GET
/generate-ice-servers 401'd. Symmetric NAT clients then fell back
to STUN-only ICE.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 2, 2026

🦋 Changeset detected

Latest commit: c962b1a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
partytracks Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@thanipro thanipro changed the title partytracks: pass fetchImpl on /generate-ice-servers fetch Honor options.fetch on /generate-ice-servers request May 2, 2026
@tranqbay tranqbay closed this by deleting the head repository May 2, 2026
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