Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ERROR [Better Auth]: Failed to create user BSONVersionError: Unsupported BSON version, bson types must be from bson 6.x.x #13322

@skipzero

Description

@skipzero

Adapter type

@auth/fauna-adapter, @auth/mongodb-adapter

Environment

Env Info:

  System:
    OS: macOS 26.0.1
    CPU: (14) arm64 Apple M4 Max
    Memory: 382.17 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.6.0 - /Users/phoenix/.nvm/versions/node/v23.6.0/bin/node
    npm: 11.6.2 - /Users/phoenix/.nvm/versions/node/v23.6.0/bin/npm
    pnpm: 10.20.0 - /Users/phoenix/.nvm/versions/node/v23.6.0/bin/pnpm
    bun: 1.3.2 - /Users/phoenix/.bun/bin/bun
  Browsers:
    Chrome: 142.0.7444.135
    Chrome Canary: 144.0.7524.0
    Firefox: 142.0.1
    Safari: 26.0.1

Project Info:

macOs 26.0.1

[create better-t-stack](https://github.com/AmanVarshney01/create-better-t-stack)

better-auth 1.3.28
Mongodb 7.0.0
Mongoose 8.19.3
next 16.0.0
typescript 5.9.3


Reproduction URL

https://github.com/skipzero/chat-app/tree/user-list

Describe the issue

trying to sign up or login with existing account results in the bson error
on sign up...
Image

server log...
Image

same log on signing in if there's already an account created.

How to reproduce

I was getting warnings about mongo being an external package and conflicting version so I got mongo and mongoose to both have matching versions across the project and not throw errors/warnings. Now I get the bson issue.

Clone the repo/branch above and install regularly (npm i, pnpm..., etc). Navigate to the signup/sign in pages and enter requested info and observe the server console throw the error and nothing is added to the mongoDB.
I'm using a local copy of mongo at localhost:3001/27017. Environmental variables are...

DATABASE_URL=mongodb://localhost:27017/<DB_NAME>
BETTER_AUTH_SECRET=<AUTH_SECRET>
BETTER_AUTH_URL=http://localhost:3001
CORS_ORIGIN=http://localhost:3001

Expected behavior

I would expect a new user added if I were signing up and a new session initialised if I were signing in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    adaptersChanges related to the core code concerning database adaptersbugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions