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

_id no longer recursive when another version of bson in installed #15140

Open
2 tasks done
BobBatard opened this issue Dec 31, 2024 · 2 comments
Open
2 tasks done

_id no longer recursive when another version of bson in installed #15140

BobBatard opened this issue Dec 31, 2024 · 2 comments
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity

Comments

@BobBatard
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

8.9.1

Node.js version

20.7.0

MongoDB server version

8.0.1

Typescript version (if applicable)

No response

Description

I experienced something quite similar to this closed issue #14867

Following a mongoose update (8.9.1) in my project (with yarn) without any problem, for whatever reason I decided to delete the yarn.lock file to regenerate it, and encountered the issue described by @gl-aagostino
The recursiveness worked when creating an ObjectId in code, but fails when loading a document from the db

Turns out this version of mongoose uses bson@6.10.1, and bson@6.1.0 was also in my package.json
Updating bson to 6.10.1 resolved the problem

Not sure if it's a yarn, mongoose or bson issue, but couldn't find talks about this anywhere else

Steps to Reproduce

create a project with mongoose@8.9.1 and bson@6.1.0
insert a doc in db and find it
doc._id._id should crash

Expected Behavior

doc._id._id should not crash

@BobBatard BobBatard changed the title _id no longer recursive when bson in installed _id no longer recursive when another version of bson in installed Dec 31, 2024
@vkarpov15
Copy link
Collaborator

Can you please provide some code samples that demonstrate this issue? doc._id._id not existing means most likely you're somehow converting a Mongoose document's bson@6.10.1 ObjectId into a bson@6.1.0 ObjectId

@vkarpov15 vkarpov15 added the needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity label Jan 6, 2025
@BobBatard
Copy link
Author

BobBatard commented Jan 6, 2025

Attached is a simple project which creates a document in db, finds it, then logs doc._id._id
Only mongoose is specified in package.json

steps to reproduce the bug :

yarn install
# logs an _id
yarn start
yarn add bson@6.1.0
# logs undefined
yarn start 
yarn add bson@6.10.1
# logs an _id
yarn start

mongoose-bson.zip

@BobBatard BobBatard reopened this Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity
Projects
None yet
Development

No branches or pull requests

2 participants