Skip to content

fix: wait for Connect.lookup_or_start_connection to be ready #1466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2025

Conversation

edgurgel
Copy link
Member

What kind of change does this PR introduce?

This helps with cold starts as multiple websocket connections might happen at the same time.

Scenario 1:

  • Connect.lookup_or_start_connection is called once;
  • Connect process starts up so syn already registered the process;
  • Another Connect.lookup_or_start_connection is called and syn already acknowledges that a Connect for that tenant exists but no conn has been assigned yet to the syn metadata;
    • Current behaviour is to return an error;
    • New behaviour is to subscribe for the Syn event with the updated metadata;
    • If the event arrives we consider that the connection is ready. After 5 seconds we give up.

Scenario 2:

  • Connect.lookup_or_start_connection is called from multiple nodes very quickly;
  • These RPC calls will most likely land on the same node calling the same DynamicSupervisor on the same partition which means that one of them will proceed creating while the other ones will block and eventually get :already_started;
  • This is the happy path because these processes will wait for the first process to finish its init which will already have a conn set.

Additional context

Add any other context or screenshots.

Copy link

vercel bot commented Jul 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
realtime-demo ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2025 0:52am

@coveralls
Copy link

coveralls commented Jul 17, 2025

Coverage Status

coverage: 85.292% (+0.1%) from 85.146%
when pulling a15a1f3 on fix/connect-lookup-cold-start
into 1efdf78 on main.

This helps with cold starts as multiple WebSocket connections might
happen at the same time
@edgurgel edgurgel force-pushed the fix/connect-lookup-cold-start branch from 17f62bf to 9b98064 Compare July 22, 2025 09:51
@edgurgel edgurgel merged commit 22b3a62 into main Jul 23, 2025
6 of 8 checks passed
@edgurgel edgurgel deleted the fix/connect-lookup-cold-start branch July 23, 2025 01:29
@kiwicopple
Copy link
Member

🎉 This PR is included in version 2.41.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants