Skip to content

fix(dev): load one better-auth module in the dev worker - #712

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
0froq:fix/dev-single-better-auth
Nov 4, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
0froq:fix/dev-single-better-auth

Conversation

@0froq

@0froq 0froq commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Fixes #686

Description

void_worker excluded void from dependency optimization but not better-auth, so an app import of better-auth/api was prebundled while the runtime loaded the package from source. OAuth request state lives on a module-local ref, so getOAuthState() missed the state the runtime set. Workerd environments, including void_worker, now exclude better-auth as well so both sides resolve to the same source module. Production bundling is unchanged. No new config flag.

Test

  • Without the exclude, the dev route returned { same: false }
  • vp test run packages/void/test/unit/plugin-better-auth-dev.test.ts packages/void/test/unit/plugin-dev-asset-routing.test.ts packages/void/test/unit/plugin-vite-environment.test.ts -t 'OAuth state|CommonJS dependencies|void/db driver'
  • vp run --filter ./packages/void typecheck

The workerd dependency optimizer excluded void, so an app import of
better-auth/api was prebundled while Void's runtime loaded the package
from source. OAuth request state lives on a module-local ref, and
getOAuthState() then missed the state the runtime set. Exclude
better-auth in those environments as well.

Co-authored-by: sayhola <sayhola@froq.me>

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@cpojer
cpojer merged commit 229458a into voidzero-dev:main Nov 4, 2026
18 checks passed
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.

Dev server: plugins importing better-auth/api get a second copy of Better Auth's request state, so getOAuthState() is null in a plugin's callback hook

3 participants