Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug when Using mongoose session #15552

Open
wrjcs opened this issue Dec 3, 2024 · 2 comments
Open

bug when Using mongoose session #15552

wrjcs opened this issue Dec 3, 2024 · 2 comments
Labels
bug Something isn't working bundler Something to do with the bundler needs repro Needs an example to reproduce

Comments

@wrjcs
Copy link

wrjcs commented Dec 3, 2024

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

@wrjcs wrjcs added bug Something isn't working needs triage labels Dec 3, 2024
@cirospaciari cirospaciari added the needs repro Needs an example to reproduce label Dec 6, 2024
Copy link
Contributor

github-actions bot commented Dec 6, 2024

Hello @wrjcs. Please provide a minimal reproduction using a GitHub repository, Replit, CodeSandbox, or provide a bulleted list of commands to run that reproduce this issue. Issues marked with needs repro will be closed if they have no activity within 3 days.

@cirospaciari
Copy link
Member

Can you show a little code that I can run to reproduce the issue?
Note to self: Automattic/mongoose#6663

@nektro nektro added bundler Something to do with the bundler and removed needs triage labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bundler Something to do with the bundler needs repro Needs an example to reproduce
Projects
None yet
Development

No branches or pull requests

3 participants