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
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 52/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript, vite
- Bereich
- build-system, devtools
Rechercherichtung
Start by tracing how the void_worker environment configures Vite dependency optimization and how Void loads Better Auth at runtime; the report identifies defineRequestState in @better-auth/core as the source of the module-local ref. Reproduce with the described OAuth callback and compare against the better-auth exclusion in vite.config.ts. Done means the callback hook and Void runtime share request state in dev; verify the reported reproduction and relevant tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Void 1.5.0, better-auth 1.7.15, vite 8.3.5, @cloudflare/vite-plugin 2.0.0-beta.v.10, sqlite dialect, void dev.
A Better Auth plugin added in auth.ts registers an after hook on /callback/* and calls getOAuthState() from better-auth/api to read serverContext that the same plugin set with addOAuthServerContext() before calling signInSocial. On the dev server the hook gets null, although the state row in the verification table holds the serverContext and ctx.context.newSession is set. The same plugin works with betterAuth() used directly, outside Void.
Cause, as far as we can tell: Better Auth keys request state by a module-local ref (defineRequestState in @better-auth/core creates const ref = Object.freeze({}) per call; only the AsyncLocalStorage is on globalThis). The worker environment's optimizeDeps excludes void, so Void's runtime (which creates the auth instance and runs the callback) and user code importing better-auth/api (pre-bundled by Vite) load different instances of better-auth/dist/api/state/oauth.mjs. The callback's setOAuthState and the plugin's getOAuthState use different refs. Void already works around the same class of duplicate for its own auth ALS (authContext on a Symbol.for key).
Workaround: environments: { void_worker: { optimizeDeps: { exclude: ['better-auth'] } } } in vite.config.ts, after which the hook sees the state. A production build bundles one copy and is not affected.
Expected: user code and Void's runtime share one instance of better-auth on the dev server, for example by pre-bundling better-auth with Void's runtime, or by Void excluding better-auth along with itself.
Repro: a plugin with addOAuthServerContext({ x: 1 }) + signInSocial()(…) in a GET endpoint, and an after hook on /callback/ logging (await getOAuthState())?.serverContext. Run the flow against any OAuth provider (for example oauth2-mock-server through genericOAuth). It logs null under void dev and { x: 1 } with the exclusion above.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 627
- Forks
- 66
- Ø Merge
- 14 Std. 38 Min.
- Gemergte PRs (30 T.)
- 179
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus voidzero-dev/void
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
voidzero-dev/void#677 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 30/100
voidzero-dev/void#689 ·
Maintainer antworten meist innerhalb von 1 Tag
-
`VoidActionError.message` ignores the server's message, though the docs show it to usersEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 52/100
voidzero-dev/void#680 ·
Maintainer antworten meist innerhalb von 1 Tag
-
`withValidator({ body })` rejects the multipart bodies that `useForm` and `action()` send for filesOffen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
voidzero-dev/void#679 ·
Maintainer antworten meist innerhalb von 1 Tag
-
`Link`: mark the link to the current page (`aria-current`, `data-active`)Evtl. vergeben @yangshun hat das vor 1 Tag übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
voidzero-dev/void#676 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in voidzero-dev/void
Ähnliche Issues
-
needs investigation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 60/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
area:visualizer tech-debt
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 66/100
jmbarzee/temporal-architect#292 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
riverqueue/river#1576 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
colbymchenry/codegraph#3228 ·
Maintainer antworten meist innerhalb von 1 Tag