Repository navigation
Conversation
getNextBestRegionUrl threw when the cached region list had expired and the region settings endpoint was unreachable. The old list is still a better choice than a failed connection. A cancel or a rejected token (401) still throws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
This PR bumps
|
Contributor
size-limit report 📦
|
xianshijing-lk
approved these changes
Nov 20, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
On LiveKit Cloud, the SDK picks a region from a cached region list. The region settings endpoint sends a
max-age, and the cached list expires at that age. Today, if the list is expired and the endpoint is unreachable,getNextBestRegionUrlthrows, and the connection or the full reconnect fails. An expired list still names regions that most likely work, so the SDK can try them instead of failing.Change
If the refresh fails,
getNextBestRegionUrluses the expired list and logs a warning. The failed refresh does not change the cache entry. The background refetch keeps retrying on its own schedule.Three cases still throw:
Cancelled). An aborted reconnect must stop.NotAllowed). The signal connection rejects the same token, and the background refetch already treats this error as final.Verified
npx vitest run src/room/RegionUrlProvider.test.ts: 53 tests pass. The testfalls back to the expired cache when the refresh failsexpires the cache and then makes the refresh fail, first with a 500 and then with a network error. Both calls return the cached region. The testdoes not fall back to the expired cache when the token is rejectedmakes the refresh return a 401 and expects aNotAllowederror.preserves cache when one instance fails to fetchexpected that a 500 from the refresh throws. The new fallback test replaces it.npx tsc --noEmitpasses.Checklist
🤖 Generated with Claude Code