Skip to content

Conversation

davidzhao
Copy link
Member

When using Cloud, establish connection to fetch region URL so we have better control of routing decisions.

For projects with region-pinning enabled, /settings/regions would only return regions that are allowed. if prepareConnections is not used, Cloud would reject the initial connection if DNS-based routing ends up connecting to a disallowed region.

@davidzhao davidzhao requested review from paulwe, boks1971 and lukasIO July 12, 2023 07:48
@changeset-bot
Copy link

changeset-bot bot commented Jul 12, 2023

🦋 Changeset detected

Latest commit: 49a862b

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

This PR includes changesets to release 1 package
Name Type
livekit-client 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

@github-actions
Copy link
Contributor

github-actions bot commented Jul 12, 2023

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 86.01 KB (+0.29% 🔺)
dist/livekit-client.umd.js 91.03 KB (+0.31% 🔺)

Copy link
Contributor

@boks1971 boks1971 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lg!

src/room/Room.ts Outdated
// trigger the first fetch without waiting for a response
// if initial connection fails, this will speed up picking regional url
// on subsequent runs
this.regionUrlProvider.fetchRegionSettings().catch((e) => {
Copy link
Contributor

@lukasIO lukasIO Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line can go after the else clause so that it runs even if regionUrlProvider has been set by a previous prepareConnection call already?
also on disconnect we currently don't clear the regionUrlProvider. so with the sequence connect -> disconnect -> connect we would skip fetching region settings the second time around currently.
would probably make sense to at least resetAttempts of the url provider on disconnect/engine closing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah makes sense. it should clear out all the previous urls + providers as the primary url may have changed. I'll make that change

Copy link
Contributor

@lukasIO lukasIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just some minor comments.

@davidzhao davidzhao merged commit 264a0ca into main Jul 15, 2023
@davidzhao davidzhao deleted the prewarm-regions branch July 15, 2023 17:14
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.

4 participants