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
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 52/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- typescript, vite
- Domínio
- build-system, devtools
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 627
- Forks
- 66
- Merge médio
- 14h 38min
- PRs com merge (30d)
- 179
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de voidzero-dev/void
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
voidzero-dev/void#677 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 30/100
voidzero-dev/void#689 ·
Mantenedores costumam responder em até 1 dia
-
`VoidActionError.message` ignores the server's message, though the docs show it to usersTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 52/100
voidzero-dev/void#680 ·
Mantenedores costumam responder em até 1 dia
-
`withValidator({ body })` rejects the multipart bodies that `useForm` and `action()` send for filesAberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
voidzero-dev/void#679 ·
Mantenedores costumam responder em até 1 dia
-
`Link`: mark the link to the current page (`aria-current`, `data-active`)Talvez já em andamento @yangshun assumiu hoje. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
voidzero-dev/void#676 · 2 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de voidzero-dev/void
Issues semelhantes
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
-
bug needs triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
DSpace/dspace-angular#6511 ·
Mantenedores costumam responder em até 1 dia
-
area: frontend area:byok bug severity:low
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
Mantenedores costumam responder em até 1 dia
-
Phone app shows Unknown for a remote machine whose key changedTalvez já em andamento @janicduplessis assumiu hoje. Abertaarea: mobile priority: P3 type: bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
appandflow/stim#5006 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Area - Local to Cloud Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
microsoft/vscode-mssql#23209 ·
Mantenedores costumam responder em até 1 dia