meteor / meteor/meteor

MongoDB Node.js driver's ObjectId is an empty object on client

Open
#12,029 10 comments 3 reactions 0 assignees View on GitHub
idle Project:Minimongo
Dominant language
JavaScript
Stars
44.8k
Forks
5.2k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Summary
While trying to update our app from Meteor 2.5.6 to 2.7.1 I've noticed the following issue:
If a document have a field of type `ObjectId` (MongoDB Node.js driver's one, not Meteor's `Mongo.OjbectID`) and we send this document to the client via `Meteor.methods` then on the client that field arrives as an empty object though previously it has arrived as an object with `_bsontype` and `id` fields which we tend to use on the client.

### Steps to reproduce (Meteor 2.7.1)
1. `git clone git@github.com:baryshok/meteor-test-objectid-271.git`
2. `meteor npm i`
3. `meteor`
4. Open `http://localhost:3000` in browser
5. Click on "Click Me" button
6. Check the browser's console – `oid` field should be an empty object:

![B572B21C-DE3C-4A8B-9118-49F22E99853D](https://user-images.githubusercontent.com/16780712/167315560-a8845a52-2057-4142-b76a-97347fe22fc2.png)

### How it used to be (Meteor 2.5.6)
1. `git clone git@github.com:baryshok/meteor-test-objectid-256.git`
1. `meteor npm i`
2. `meteor`
3. Open `http://localhost:3000` in browser
4. Click on "Click Me" button
5. Check the browser's console – `oid` field should be an object containing `_bsontype` and `id` fields:

![38141136-C9D4-4D31-B085-75CF13F2AB32](https://user-images.githubusercontent.com/16780712/167315826-30a3f324-6efa-4725-bad6-1473e0e3b94f.png)
---
Operating system: MacOS 12.3.1

I'm sure that this issue is directly related to the update of MongoDB Node.js driver in Meteor 2.6 and I hope that it's possible to get back the `_bsontype` and `id` fields.

### This bug report should include:
- [x] A short, but descriptive title. The title doesn't need "Meteor" in it.
- [x] The version of Meteor showing the problem.
- [x] The last version of Meteor where the problem did _not_ occur, if applicable.
- [x] The operating system you're running Meteor on.
- [x] The expected behavior.
- [x] The actual behavior.
- [x] A **simple** reproduction! (Must include the Github repository and steps to reproduce the issue on it.)

If you don't include a reproduction the issue is probably going to be closed.

### Independent packages

Please ensure your issue is opened in the appropriate repository:

* Feature Requests: https://github.com/meteor/meteor/discussions
* Blaze: https://github.com/meteor/blaze/
* Galaxy Guide: https://github.com/meteor/galaxy-docs/
-->

Contributor guide

Open the contributing guide

Research direction

Start with the linked reproduction repositories meteor-test-objectid-271 and meteor-test-objectid-256, then trace the ObjectId value returned through Meteor.methods to the client. Compare the serialization behavior between Meteor 2.5.6 and 2.7.1. Done means the client receives the expected ObjectId representation, or the changed behavior is documented and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, nodejs
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.