Skip to content

Stop the region failover on a 401 - #1707

Open
lukasIO wants to merge 2 commits into
mainfrom
lukas/region-auth-final
Open

lukasIO wants to merge 2 commits into
mainfrom
lukas/region-auth-final

Conversation

@lukasIO

@lukasIO lukasIO commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

A token that the server rejects fails in every region, but SignalClient::connect still tried every region of a LiveKit Cloud project after a 401 from rtc/validate. The region cache also served its expired list after the region endpoint returned a 401. The JS SDK stops on a 401 in both places.

Change

  • SignalClient::connect returns a Client(401) without the region fallback. A 403 still fails over, as in the JS SDK.
  • RegionUrlProvider::fetch_region_urls returns a 401 even when it has an expired list.
  • If the dial fails without an auth status, for example because rtc/validate timed out, and region discovery returns a 401, connect returns that 401 instead of the dial error. The engine stops retrying only on Client(401|403).
  • The region_failover doc comment said that every error, including a 401, starts the fallback. It now names the 401 as the exception.

Verified

  • cargo test -p livekit-signaling: 56 tests pass.
  • connect_skips_region_fallback_on_401: the WebSocket upgrade and rtc/validate return 401, and the region endpoint serves a list. Without the change, the connect tries the region and returns that region's error.
  • stale_regions_are_not_served_after_a_401: an expired list in the cache and a 401 from the fetch. Without the change, the expired list comes back.
  • connect_returns_a_401_from_region_discovery: the dial fails with a 503, rtc/validate passes, and the region endpoint returns 401. Without the change, the 503 comes back.
  • All three tests fail without their change.

🤖 Generated with Claude Code

A token that the server rejects fails in every region. SignalClient::connect
no longer starts the region fallback on a Client(401) from rtc/validate, and
fetch_region_urls no longer serves an expired region list after the region
endpoint returns a 401. A 403 still fails over, as in the JS SDK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukasIO
lukasIO requested a review from ladvoc as a code owner November 21, 2026 11:43
@lukasIO lukasIO self-assigned this Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Changeset ✓

This PR includes a changeset covering all affected packages:

Package Bump
livekit patch
livekit-api patch
livekit-capture patch
livekit-ffi patch
livekit-signaling patch

devin-ai-integration[bot]

This comment was marked as resolved.

When the dial failed without an auth status, for example because
rtc/validate timed out, connect replaced a 401 from the region endpoint
with the dial error. The engine then kept retrying the rejected token,
because it stops only on Client(401|403).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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