bug when Using mongoose session #15552
Labels
bug
Something isn't working
bundler
Something to do with the bundler
needs repro
Needs an example to reproduce
What version of Bun is running?
1.1.38
What platform is your computer?
Linux 5.4.0-200-generic x86_64 x86_64
What steps can reproduce the bug?
Hello,
I use mongoose session in my project.
When I run with bun server.js, It works.
But when I compile with
bun build --compile --minify --sourcemap --bytecode ./server.js --outfile test --no-treeshake
It throw bug
[2024-12-03T18:25:07.251] [ERROR] default - erro:ClientSession cannot be serialized to BSON.
Error: ClientSession cannot be serialized to BSON.
at new _F (node_modules/mongoose/node_modules/mongodb/lib/error.js:119:9)
at new AW (node_modules/mongoose/node_modules/mongodb/lib/error.js:217:9)
at new N7 (node_modules/mongoose/node_modules/mongodb/lib/error.js:276:9)
at toBSON (node_modules/mongoose/node_modules/mongodb/lib/sessions.js:423:27)
at Cm (node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:410:29)
at (node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:347:10)
at (node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:308:14)
at (node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:224:14)
at (node_modules/mongoose/lib/query.js:2645:45)
at F (node_modules/mongoose/lib/query.js:2653:4)
at (node_modules/mongoose/lib/query.js:4458:74)
at processTicksAndRejections (native:7:39)
this is my simple code
var session = await Cart.startSession();
await session.startTransaction();
await this.calculateTotalWithTax();
var c = await Customer.findOne({}).session(session);
the last line will throw the error.
this version mongoose i use
"mongodb": "^6.11.0",
"mongoose": "^8.8.3",
Could you help me?
Thanks.
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: