From 9058c35b1f40d79c62495ac4975d49bf0d727bdd Mon Sep 17 00:00:00 2001 From: Donald Silveira Date: Wed, 2 Dec 2026 11:14:53 -0300 Subject: [PATCH] fix(auth): stop OAuth discovery from failing with 500 on Workers Better Auth's runtime schema check is one promise per isolate, started in the background of the request that builds the instance. On Workers, a request that ends first (an unauthenticated MCP call answers 401 at once) leaves it unable to settle, and every later request in that isolate fails. getAuth already migrates the schema, so the runtime check is off. Co-Authored-By: Claude Opus 5.5 --- src/features/auth/auth.server.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/features/auth/auth.server.ts b/src/features/auth/auth.server.ts index 8cd6d10..318cdd0 100644 --- a/src/features/auth/auth.server.ts +++ b/src/features/auth/auth.server.ts @@ -97,6 +97,12 @@ function createAuth() { }, database: { joins: true, // Enable database joins for better performance + // `getAuth` migrates the schema itself. Better Auth's own check is + // one promise per isolate, started in the background of the request + // that builds the instance; on Workers a request that ends first + // (an unauthenticated MCP call, say) leaves it unable to settle, and + // every later request in that isolate fails with a 500. + validateSchema: false, }, }, plugins: [