Repository navigation
Report ignored client options, never connect on the server - #62
Merged
Merged
Conversation
- setupConvex() / initConvex() create the client with disabled forced on the server (typeof document at runtime), even if a caller passes disabled: false. Previously setupConvex derived it from esm-env's build-time BROWSER and let callers override it, so a caller passing disabled: false opened a WebSocket during server rendering. - The singleton remembers the options it was created with. When setupConvex() or a repeated initConvex() passes different primitive options (e.g. expectAuth in the layout while initConvex() in hooks.ts created the client), a dev warning in the browser names them instead of dropping them silently. Like the ConvexReactClient constructor, options only apply where the client is created.
mmailaender
force-pushed
the
fix/convexload-single-subscription
branch
from
October 12, 2026 15:27
c784afb to
5afe992
Compare
mmailaender
force-pushed
the
fix/client-options
branch
from
October 12, 2026 15:27
ddde9a1 to
77fe505
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
mmailaender
marked this pull request as ready for review
October 13, 2026 05:38
mmailaender
changed the base branch from
fix/convexload-single-subscription
to
main
October 13, 2026 05:49
mikecann
approved these changes
Oct 14, 2026
mikecann
left a comment
Member
There was a problem hiding this comment.
Thanks Micha, looks good! Really nice that the server client can never open a WebSocket now.
commit: |
This branch was successfully 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.
Summary
ConvexReactClientconstructor. WhensetupConvex()or a repeatedinitConvex()passes options the existing client was not created with, a dev warning now names them. Before, they were dropped silently.disabled: false, and that is decided at runtime instead of by how the bundler resolvesesm-env.PUBLIC_CONVEX_URL). The new server-guard test fails against the oldinitConvex.Before / after (user code)
The fix in user code is to pass the options where the client is created:
initConvex(PUBLIC_CONVEX_URL, { expectAuth: true }).Why
Silent option dropping. convex-svelte creates the shared client in two places:
initConvex(), needed inhooks.tsbefore loads and transport decoding runsetupConvex(), in the root layoutThe second call reuses the client and dropped its options without a word. This happens in practice: wrappers like
@mmailaender/convex-better-auth-sveltepass client options through tosetupConvex(), and the get-convex/better-auth SvelteKit guide recommendedcreateSvelteAuthClient({ options: { expectAuth: true } }). In apps that also callinitConvex(), that had no effect.React avoids the problem by design: the user creates the client once with all options and the provider only receives it. Svelte can't simply copy that, because SvelteKit loads need the client before any component exists. Reporting the conflict keeps the same rule ("options apply where the client is created") without an API change.
WebSocket on the server.
setupConvex()computed{ disabled: !BROWSER, ...options }. Two problems:disabled: falsewon.@mmailaender/convex-better-auth-sveltepassed exactly that, so in apps withoutinitConvex()the client it created during SSR opened a WebSocket on the server that lived as long as the process. Measured in SvelteKit 2 and 3 dev and production builds; fixed in the wrapper in fix(svelte): stop forcing the Convex client on during SSR mmailaender/convex-better-auth-svelte#52.BROWSERis fixed at build time from package export conditions.initConvex()already used a runtime check (typeof document); now both do.What
internal/client_options.ts(new):withServerDisabled(options)always setsdisabled: trueon the server.differingOptions(created, requested)compares only primitive values and ignoresdisabled. Functions and objects such asloggerorwebSocketConstructorget a new identity on every hot reload, so comparing them would only produce noise.warnIgnoredOptions()only warns in dev and in the browser, where the options matter. On the server it would log on every request.internal/singleton.ts:setSingleton(url, client, options)stores the creation options.getSingletonOptions()returns them, and they reset with the client.setupConvex()/initConvex(): create the client withwithServerDisabled(), store the options, and warn when an existing client is reused with different ones.How
setupConvex(url)with no options never warns, and neither does hot reload with unchanged options.client_options.spec.ts: server vs browserdisabled, which options count as different, and that warnings appear only in dev in the browser.sveltekit/client.spec.ts:initConvex(url, { disabled: false })on the server still creates a disabled client. This test fails against the old code.expectAuthlimitations.