fix(auth): rebuild nuxthub postgres adapters per request#295
fix(auth): rebuild nuxthub postgres adapters per request#295
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
better-auth | 966689c | Apr 22 2026, 08:01 PM |
e752578 to
c2e43a6
Compare
|
Hey @onmax Here's few issues I found:
Hence using related: cloudflare/workers-sdk#6179 |
|
@jd-solanki Please try again when you have a moment. I’ve pushed a fix for the issue on our side. |
|
Hey @onmax sorry I was not able to test it yesterday. I tried latest commit and now we have initial installation issue where we first install the packages:
Even after this error when I run dev command we get error in browser: I also check installed modules just to be sure: NOTE: I pushed latest commit of this PR to my repro if you want to try it locally: https://github.com/jd-solanki/nuxthub-better-auth-repro?rgh-link-date=2026-03-24T18%3A52%3A51.000Z |
|
@jd-solanki I pushed another fix and the fresh https://pkg.pr.new/nuxt-modules/better-auth/@onmax/nuxt-better-auth@9a4ad00 Please use this owner/repo-qualified URL instead of the compact I tested it against your repro locally and I could no longer reproduce the |
|
Hey @onmax I tried latest commit but still facing following:
I updated package lock to exact commit this time so now if you pull latest changes and run BTW it's surpring to me that your I request you to also validate when you have in your For example, with pkg.pr command import { useRuntimeConfig } from "nitropack/runtime";instead of import { useRuntimeConfig } from "#imports"; |
|
I retried this from a fresh Please avoid the Please also use the owner/repo-qualified rm -rf node_modules .nuxt
pnpm install https://pkg.pr.new/nuxt-modules/better-auth/@onmax/nuxt-better-auth@9a4ad00
pnpm devI verified this long URL resolves to the current package build for this PR. If it still fails, please paste:
|
|
Steps:
|
|
With new changes 14:43:04.640 [error] Failed to load auth config: Package subpath './runtime/context' is not defined by "exports" in /opt/buildhome/repo/node_modules/.pnpm/node_modules/nitropack/package.json
14:43:04.640 at loadUserAuthConfig (node_modules/.pnpm/@onmax+nuxt-better-auth@https+++pkg.pr.new+nuxt-modules+better-auth+@onmax+nuxt-better-auth@9_3y4kncq5g2trjbycuwre5utoxe/node_modules/@onmax/nuxt-better-auth/dist/module.mjs:327:13)
14:43:04.640 at async loadAuthOptions (node_modules/.pnpm/@onmax+nuxt-better-auth@https+++pkg.pr.new+nuxt-modules+better-auth+@onmax+nuxt-better-auth@9_3y4kncq5g2trjbycuwre5utoxe/node_modules/@onmax/nuxt-better-auth/dist/module.mjs:376:22)
14:43:04.640 at async setupBetterAuthSchema (node_modules/.pnpm/@onmax+nuxt-better-auth@https+++pkg.pr.new+nuxt-modules+better-auth+@onmax+nuxt-better-auth@9_3y4kncq5g2trjbycuwre5utoxe/node_modules/@onmax/nuxt-better-auth/dist/module.mjs:391:37)
14:43:04.640 at async setup (node_modules/.pnpm/@onmax+nuxt-better-auth@https+++pkg.pr.new+nuxt-modules+better-auth+@onmax+nuxt-better-auth@9_3y4kncq5g2trjbycuwre5utoxe/node_modules/@onmax/nuxt-better-auth/dist/module.mjs:1102:9)
14:43:04.642 at async normalizedModule (node_modules/.pnpm/@nuxt+kit@4.4.2_magicast@0.5.2/node_modules/@nuxt/kit/dist/index.mjs:224:10)
14:43:04.643 at async callModule (node_modules/.pnpm/@nuxt+kit@4.4.2_magicast@0.5.2/node_modules/@nuxt/kit/dist/index.mjs:848:46)
14:43:04.643 at async installModules (node_modules/.pnpm/@nuxt+kit@4.4.2_magicast@0.5.2/node_modules/@nuxt/kit/dist/index.mjs:688:3)
14:43:04.643 at async initNuxt (node_modules/.pnpm/nuxt@4.4.2_xx4epqdvw2sfshelqhtg5nqilq/node_modules/nuxt/dist/index.mjs:7151:3)
14:43:04.643 at async loadNuxt (node_modules/.pnpm/nuxt@4.4.2_xx4epqdvw2sfshelqhtg5nqilq/node_modules/nuxt/dist/index.mjs:7385:5)
14:43:04.643 at async loadNuxt (node_modules/.pnpm/@nuxt+kit@4.4.2_magicast@0.5.2/node_modules/@nuxt/kit/dist/index.mjs:1050:9)
14:43:04.643 at async Object.run (node_modules/.pnpm/@nuxt+cli@3.34.0_@nuxt+schema@4.4.2_cac@6.7.14_magicast@0.5.2/node_modules/@nuxt/cli/dist/prepare-etx17Cow.mjs:30:16)
14:43:04.643 at async runCommand (node_modules/.pnpm/citty@0.2.1/node_modules/citty/dist/index.mjs:188:47)
14:43:04.643 at async runCommand (node_modules/.pnpm/citty@0.2.1/node_modules/citty/dist/index.mjs:185:21)
14:43:04.643 at async runMain (node_modules/.pnpm/citty@0.2.1/node_modules/citty/dist/index.mjs:285:10)
14:43:04.644
14:43:05.150 ELIFECYCLE Command failed with exit code 1.
14:43:05.435 Failed: error occurred while installing tools or dependenciesNote I updated the repro with your NuxtHub PR and betterAuth pkg switched to pkg.pr |
9a4ad00 to
2e89389
Compare






Closes #294
Summary
Hyperdrive-backed NuxtHub PostgreSQL auth requests were reusing state across Worker requests in two places: the module-level Better Auth singleton and the generated Drizzle client for the NuxtHub PostgreSQL adapter. Direct
@nuxthub/dbaccess still worked, but Better Auth session or user reads could intermittently fail on deployed Workers.This patch keeps the existing cache for non-database setups, but rebuilds database-backed auth instances per request and generates a fresh Hyperdrive
postgres-jsclient withprepare: falsefor the NuxtHub PostgreSQL path.Scope
Rebased on current
main. The@nuxthub/dbimport-resolution work that was part of earlier revisions is now dropped — #305 landed a different fix (Nitro externals) that supersedes it.Two smaller, unrelated cleanups are being split out into their own PRs:
nitropack/runtime→#importsmigration across 3 server runtime filestest/cases/plugins-type-inferencefixture restoreStackBlitz
CLI Reproduction
The runtime bug requires a real Cloudflare Hyperdrive binding. After deploy, verify the bug repro by hitting
/api/db-check, signing up, and then repeating authenticated/api/auth-checkrequests.Verify fix