TypeError: Cannot mix BigInt and other types with database rate limiter #570

Closed
opened 2026-03-13 07:53:26 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @ammarmbe on GitHub (Jan 16, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. create a Next.js app using npx create-next-app@latest
  2. install better-auth, prisma using npm install better-auth prisma
  3. initiate prisma using npx prisma init
  4. add the below auth config to auth.ts
  5. run npx @better-auth/cli@latest generate

Current vs. Expected behavior

When using the database rate limiter, the following error is encountered:
[TypeError: Cannot mix BigInt and other types, use explicit conversions]

This issue seems to occur because the rateLimit.lastRequest is being returned as a bigint from Prisma.

What version of Better Auth are you using?

1.1.14

Provide environment information

- OS: Windows 11 build 22631.4602
- Browser: Chrome v131.0.6778.265
- Runtime: Node.js v20.18.0

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

Package

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: "postgresql",
  }),
  rateLimit: {
    enabled: true,
    storage: "database",
  },
});

Additional context

No response

Originally created by @ammarmbe on GitHub (Jan 16, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. create a Next.js app using `npx create-next-app@latest` 2. install better-auth, prisma using `npm install better-auth prisma` 3. initiate prisma using `npx prisma init` 4. add the below auth config to auth.ts 5. run npx `@better-auth/cli@latest generate` ### Current vs. Expected behavior When using the database rate limiter, the following error is encountered: `[TypeError: Cannot mix BigInt and other types, use explicit conversions]` This issue seems to occur because the `rateLimit.lastRequest` is being returned as a bigint from Prisma. ### What version of Better Auth are you using? 1.1.14 ### Provide environment information ```bash - OS: Windows 11 build 22631.4602 - Browser: Chrome v131.0.6778.265 - Runtime: Node.js v20.18.0 ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", }), rateLimit: { enabled: true, storage: "database", }, }); ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 07:53:26 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#570