App crashing with message adapter.transaction is not a function #2062

Closed
opened 2026-03-13 09:24:01 -05:00 by GiteaMirror · 8 comments
Owner

Originally created by @Micnubinub on GitHub (Oct 2, 2025).

Originally assigned to: @himself65 on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Create custom adapter without transaction
  2. Set transaction option to false
  3. Run OAuth signup (google)

Current vs. Expected behavior

App is crashing with:

ERROR [Better Auth]: TypeError: adapter.transaction is not a function. (In 'adapter.transaction(async (trxAdapter)const createdUser = await createWithHooks({
 createdAt: new Date,
 updatedAt: new Date,
 ...user2
}, "user", void 0, context, trxAdapter), createdAccount = await createWithHooks({
 ...account,
 userId: createdUser.id,
 createdAt: new Date,
 updatedAt: new Date
}, "account", void 0, context, trxAdapter);
  return {
   user: createdUser,
   account: createdAccount
  };
})', 'adapter.transaction' is undefined)

Seems to be a issue in packages > better-auth > src > db > TS internal-adapter.ts > createlnternalAdapter > createOAuthUser. Should there be a check there if the adapater supports transactions?

What version of Better Auth are you using?

1.3.24

System info

{
  "system": {
    "platform": "linux",
    "arch": "x64",
    "version": "#84-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep  5 22:36:38 UTC 2025",
    "release": "6.8.0-84-generic",
    "cpuCount": 6,
    "cpuModel": "AMD EPYC Processor (with IBPB)",
    "totalMemory": "11.68 GB",
    "freeMemory": "9.63 GB"
  },
  "node": {
    "version": "v24.9.0",
    "env": "development"
  },
  "packageManager": {
    "name": "bun",
    "version": "1.2.23"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "1.3.24",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @Micnubinub on GitHub (Oct 2, 2025). Originally assigned to: @himself65 on GitHub. ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce 1. Create custom adapter without `transaction` 2. Set `transaction` option to false 3. Run OAuth signup (google) ### Current vs. Expected behavior App is crashing with: ```log ERROR [Better Auth]: TypeError: adapter.transaction is not a function. (In 'adapter.transaction(async (trxAdapter)const createdUser = await createWithHooks({ createdAt: new Date, updatedAt: new Date, ...user2 }, "user", void 0, context, trxAdapter), createdAccount = await createWithHooks({ ...account, userId: createdUser.id, createdAt: new Date, updatedAt: new Date }, "account", void 0, context, trxAdapter); return { user: createdUser, account: createdAccount }; })', 'adapter.transaction' is undefined) ``` Seems to be a issue in `packages > better-auth > src > db > TS internal-adapter.ts > createlnternalAdapter > createOAuthUser`. Should there be a check there if the adapater supports transactions? ### What version of Better Auth are you using? 1.3.24 ### System info ```bash { "system": { "platform": "linux", "arch": "x64", "version": "#84-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 5 22:36:38 UTC 2025", "release": "6.8.0-84-generic", "cpuCount": 6, "cpuModel": "AMD EPYC Processor (with IBPB)", "totalMemory": "11.68 GB", "freeMemory": "9.63 GB" }, "node": { "version": "v24.9.0", "env": "development" }, "packageManager": { "name": "bun", "version": "1.2.23" }, "frameworks": null, "databases": null, "betterAuth": { "version": "1.3.24", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the adapter label 2026-03-13 09:24:01 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 2, 2025):

This crash is caused by Better Auth calling adapter.transaction without checking if it exists, which leads to a TypeError when your custom adapter doesn't implement that method—even if you set transaction: false. This is a known gap: the code assumes all adapters provide a transaction method, but custom adapters (or some database drivers) may not, and there's no runtime check or fallback in createOAuthUser or related logic. This is a valid bug/feature gap for GitHub, as the framework should either check for transaction support or provide a fallback for sequential execution when transactions are disabled or unsupported [source].

Recent updates to Better Auth's adapter system added a transaction option to the adapter config, allowing you to set transaction: false for databases that don't support transactions. However, some adapters and internal code paths still don't consistently forward or respect this option, and the runtime check is missing in some places [source][source].

Workarounds include patching your local Better Auth install to ensure the transaction option is forwarded and handled, or implementing a no-op transaction method in your custom adapter that just runs the callback directly (effectively running operations sequentially). Disabling transactions globally is only recommended if your database truly doesn't support them, as you lose atomicity and rollback safety [source].

This is suited for GitHub as a bug report or feature request, since the framework should handle adapters without transaction support more gracefully.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Oct 2, 2025): <!-- Answer --> This crash is caused by Better Auth calling adapter.transaction without checking if it exists, which leads to a TypeError when your custom adapter doesn't implement that method—even if you set transaction: false. This is a known gap: the code assumes all adapters provide a transaction method, but custom adapters (or some database drivers) may not, and there's no runtime check or fallback in createOAuthUser or related logic. This is a valid bug/feature gap for GitHub, as the framework should either check for transaction support or provide a fallback for sequential execution when transactions are disabled or unsupported [[source](https://github.com/better-auth/better-auth/blob/f6cbdcc84ee5d2971fdcc8b23ff7c174f88cf45b/packages/better-auth/src/db/internal-adapter.ts)]. Recent updates to Better Auth's adapter system added a transaction option to the adapter config, allowing you to set transaction: false for databases that don't support transactions. However, some adapters and internal code paths still don't consistently forward or respect this option, and the runtime check is missing in some places [[source](https://github.com/better-auth/better-auth/pull/4414)][[source](https://github.com/better-auth/better-auth/issues/4732)]. Workarounds include patching your local Better Auth install to ensure the transaction option is forwarded and handled, or implementing a no-op transaction method in your custom adapter that just runs the callback directly (effectively running operations sequentially). Disabling transactions globally is only recommended if your database truly doesn't support them, as you lose atomicity and rollback safety [[source](https://github.com/better-auth/better-auth/issues/4732)]. This is suited for GitHub as a bug report or feature request, since the framework should handle adapters without transaction support more gracefully. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/bc646adc-1a44-4f60-8ad1-0bb019de6a68?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/bc646adc-1a44-4f60-8ad1-0bb019de6a68?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/bc646adc-1a44-4f60-8ad1-0bb019de6a68?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/bc646adc-1a44-4f60-8ad1-0bb019de6a68?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bc646adc-1a44-4f60-8ad1-0bb019de6a68?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/bc646adc-1a44-4f60-8ad1-0bb019de6a68?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/bc646adc-1a44-4f60-8ad1-0bb019de6a68?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5035)
Author
Owner

@himself65 commented on GitHub (Oct 2, 2025):

Hi, what database are you using?

@himself65 commented on GitHub (Oct 2, 2025): Hi, what database are you using?
Author
Owner

@himself65 commented on GitHub (Oct 2, 2025):

I just double checked the code, and the adapter should have a transaction evenif it's disabled

@himself65 commented on GitHub (Oct 2, 2025): I just double checked the code, and the adapter should have a transaction evenif it's disabled
Author
Owner

@elie222 commented on GitHub (Oct 21, 2025):

Getting this error with Prisma

@elie222 commented on GitHub (Oct 21, 2025): Getting this error with Prisma
Author
Owner

@leolorenzoluis commented on GitHub (Oct 22, 2025):

@himself65 It's still happening with latest version 1.3.28

@leolorenzoluis commented on GitHub (Oct 22, 2025): @himself65 It's still happening with latest version 1.3.28
Author
Owner

@Micnubinub commented on GitHub (Oct 23, 2025):

@himself65 It's still happening with latest version 1.3.28

I think the fix is coming in 1.4:
https://github.com/better-auth/better-auth/releases/tag/v1.4.0-beta.7
Check Bug fixes > adabpter

@Micnubinub commented on GitHub (Oct 23, 2025): > [@himself65](https://github.com/himself65) It's still happening with latest version 1.3.28 I think the fix is coming in 1.4: https://github.com/better-auth/better-auth/releases/tag/v1.4.0-beta.7 Check Bug fixes > adabpter
Author
Owner

@leolorenzoluis commented on GitHub (Oct 23, 2025):

@Micnubinub Saw that but it needs to be patched in 1.3.x. No one's upgrading to a beta version atm. Also, I tried it and it still throws.

@leolorenzoluis commented on GitHub (Oct 23, 2025): @Micnubinub Saw that but it needs to be patched in 1.3.x. No one's upgrading to a beta version atm. Also, I tried it and it still throws.
Author
Owner

@elie222 commented on GitHub (Oct 23, 2025):

We fixed it by adding the refresh token expires at fields to the database schema for account

@elie222 commented on GitHub (Oct 23, 2025): We fixed it by adding the refresh token expires at fields to the database schema for account
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2062