mongodb-js/connect-mongodb-session

Unsupported BSON version, bson types must be from bson 5.x.x

Closed this issue · 14 comments

With the latest connect-mongodb-session version v4.0.0 I started to get error Unsupported BSON version, bson types must be from bson 5.x.x (node_modules/connect-mongodb-session/index.js:224:19). Other mongodb-related dependency is mongoose, which is up to date as well. What could be the issue?

Run npm list bson and paste the output here please

Not the original poster, but ran into the same issue, here's my output:

├─┬ connect-mongodb-session@4.0.0
│ └─┬ mongodb@5.9.2
│   └── bson@5.5.1
├─┬ mongodb@6.3.0
│ └── bson@6.2.0
└─┬ mongoose@8.1.0
  └── bson@6.2.0 deduped

I just bumped to 4.0.0 and started getting the same here.

Error:

Error: Error setting PeTlDY8GA6n_CujSCJLJeNxENCs9--Lt to Session {
  cookie: { path: '/', _expires: null, originalMaxAge: null, httpOnly: true },
  foo: ...,
  bar: ...
}: Unsupported BSON version, bson types must be from bson 5.x.x
    at /.../node_modules/connect-mongodb-session/index.js:224:19
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

As per the instructions above:

npm list bson

├─┬ connect-mongodb-session@4.0.0
│ └─┬ mongodb@5.9.2
│   └── bson@5.5.1
└─┬ mongoose@8.1.1
  ├── bson@6.2.0
  └─┬ mongodb@6.3.0
    └── bson@6.2.0 deduped

Ok, we'll need to create a new release using MongoDB 6.x so we can get the same bson version. Will fix.

Just shipped 5.0.0 with the fix 👍

Wow, that was fast, thanks!

I'm getting this same error @5.0.0 using Mongo Atlas

Today, I am getting a similar error after updating my modules: BSONVersionError: Unsupported BSON version, bson types must be from bson 6.x.x.

npm list bson:

├─┬ connect-mongodb-session@5.0.0
│ └─┬ mongodb@6.3.0
│ └── bson@6.4.0 deduped
└─┬ mongoose@8.2.1 invalid: "^5.7.9 || 6.x" from node_modules/@mongoosejs/double
└── bson@6.4.0

Getting the same error here

Facing same issue

Same issue

Same for me has anyone solved this ?

same issue as
Error updating metadata: BSONVersionError: Unsupported BSON version, bson types must be from bson 6.x.x
also i am updating the metadata field and start getting this error
npm ls bson is this
├─┬ mongodb@6.9.0
│ └── bson@6.8.0
├─┬ mongoose@8.7.0
│ └── bson@6.8.0 deduped
└─┬ multer-gridfs-storage@5.0.2
└─┬ @types/mongodb@3.6.20
└─┬ @types/bson@4.2.0
└── bson@6.8.0 deduped

pgeday commented

I solved this problem, but keep the problem description below, in case you have the same context.
The solution was to upgrade mongoose back to v8.7.1, which generated the following npm list bson
├─┬ mongodb@6.9.0
│ └── bson@6.8.0
└─┬ mongoose@8.7.1
└── bson@6.8.0 deduped

Notice that there is no extra mongodb branch under mongoose and the extra bson under that.

First I just moved up to mongoose v7.4.0, but got the same problem and the following bson list

├─┬ mongodb@6.9.0
│ └── bson@6.8.0
└─┬ mongoose@7.8.2
├── bson@5.5.1
└─┬ mongodb@5.9.2
└── bson@5.5.1 deduped

Original problem for context (in case other folks are trying to upgrade their mongodb clusters)
I have the same issue. I wanted to upgrade my mongodb cluster from v6 to v7. I am still on v6 right now as my mongoose update broke the app.
I first upgraded my mongoose from v6.7.3 to v8.x. It broke the whole app, first with experiment topLevelAwait webpack config problems. After I got my mongoose back to v.6.7.3 and changed the webpack config I got the bson problem (BSONVersionError: Unsupported BSON version, bson types must be from bson 6.x.x)

My npm list bson results:

├─┬ mongodb@6.9.0
│ └── bson@6.8.0
└─┬ mongoose@6.13.3
├── bson@4.7.2
└─┬ mongodb@4.17.2
└── bson@4.7.2 deduped