Problem
The common auth flow for a SpacetimeDB web app is "start anonymous, then the user signs in" — you open an anonymous connection, the user authenticates (e.g. via Google), you get a logged-in token, and you want to reconnect with it. In the Svelte binding there's no clean way to do this:
- The provider holds its connection in a module-level singleton that's reused across remounts, so even a
{#key} swap keeps the old token.
- There's no reconnect path on the context value.
- A
DbConnection's token is immutable after build(), so you can't mutate your way out either.
The only thing that actually works today is a hard window.location.reload(), which throws away all client state and flickers the UI on every sign-in/sign-out. Separately, the Svelte binding also lacks the exponential-backoff auto-reconnect that React and Solid already get from ConnectionManager, so a dropped socket just stays dropped.
Vue has the same shape (it doesn't use ConnectionManager either).
Proposed fix
I think this can be fixed cleanly by extracting and updating work that already exists in-flight:
This hangs off the reconnect tracking issue #1936.
Next step
I'll submit a pull request shortly that does both: the ConnectionManager.rebuild() primitive plus tests, then the Svelte port.
Problem
The common auth flow for a SpacetimeDB web app is "start anonymous, then the user signs in" — you open an anonymous connection, the user authenticates (e.g. via Google), you get a logged-in token, and you want to reconnect with it. In the Svelte binding there's no clean way to do this:
{#key}swap keeps the old token.DbConnection's token is immutable afterbuild(), so you can't mutate your way out either.The only thing that actually works today is a hard
window.location.reload(), which throws away all client state and flickers the UI on every sign-in/sign-out. Separately, the Svelte binding also lacks the exponential-backoff auto-reconnect that React and Solid already get fromConnectionManager, so a dropped socket just stays dropped.Vue has the same shape (it doesn't use
ConnectionManagereither).Proposed fix
I think this can be fixed cleanly by extracting and updating work that already exists in-flight:
rebuild()primitive onConnectionManagerfrom the open multi-module-provider PR feat: Multi-module React provider and ConnectionManager.rebuild() #4887 (design by @Ludv1gL) — lifted into a focused, additive change and adapted to the current post-Fix TypeScript React provider reconnect #5185 reconnect machinery.ConnectionManager(the same pool React and Solid already use), which drops the bespoke singleton, gains auto-reconnect for free, and lets the provider surface areconnect(builder)method for token swaps with no page reload.This hangs off the reconnect tracking issue #1936.
Next step
I'll submit a pull request shortly that does both: the
ConnectionManager.rebuild()primitive plus tests, then the Svelte port.