Failed to initialize database adapter

On the latest version of Better Auth on 0.8.6-beta.3 trying to sign in with OAuth causes the following error:
[_ [BetterAuthError]: Failed to initialize database adapter] {
cause: undefined
}
unhandledRejection: [_ [BetterAuthError]: Failed to initialize database adapter] {
cause: undefined
}
unhandledRejection: [_ [BetterAuthError]: Failed to initialize database adapter] {
cause: undefined
}
⨯ [_ [BetterAuthError]: Failed to initialize database adapter] {
cause: undefined
}
POST /api/auth/sign-in/social?currentURL=http%3A%2F%2Flocalhost%3A3000%2F 500 in 3229ms
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^

[_ [BetterAuthError]: Failed to initialize database adapter] {
cause: undefined
}
[_ [BetterAuthError]: Failed to initialize database adapter] {
cause: undefined
}
unhandledRejection: [_ [BetterAuthError]: Failed to initialize database adapter] {
cause: undefined
}
unhandledRejection: [_ [BetterAuthError]: Failed to initialize database adapter] {
cause: undefined
}
⨯ [_ [BetterAuthError]: Failed to initialize database adapter] {
cause: undefined
}
POST /api/auth/sign-in/social?currentURL=http%3A%2F%2Flocalhost%3A3000%2F 500 in 3229ms
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^

[_ [BetterAuthError]: Failed to initialize database adapter] {
cause: undefined
}
2 Replies
bekacru
bekacru11mo ago
was it working with the prev version? also is this the drizzle issue?
kyle
kyleOP11mo ago
Yeah I was previously on 0.6.2 (but wanna move up the version pretty much) Yeah it's the Drizzle issue, and will begin debugging the problem as I run a custom adapter. @bekacru I see that since 0.6.2 the adapters have changed in layout quite a lot is there any reason for this? Debugging now, seems to be a issue with the /src/db/utils.ts and specifically:
const { kysely, databaseType } = await createKyselyAdapter(options);
if (!kysely) {
throw new BetterAuthError("Failed to initialize database adapter");
}
const { kysely, databaseType } = await createKyselyAdapter(options);
if (!kysely) {
throw new BetterAuthError("Failed to initialize database adapter");
}
I can't really debug further but is it possible for you to pass the adapter through the options optionally? in case someone didn't wanna use the built-in kysely adapter

Did you find this page helpful?