Skip to content


Choose a tag to compare
@github-actions github-actions released this 02 Apr 16:09

6.6.0 (2024-04-01)

The MongoDB Node.js team is pleased to announce version 6.6.0 of the bson package!

Release Notes

Binary.toString and Binary.toJSON align with BSON serialization

When BSON serializes a Binary instance it uses the bytes between 0 and binary.position since Binary supports pre-allocating empty space and writing segments of data using .put()/.write(). Erroneously, the toString() and toJSON() methods did not use the position property to limit how much of the underlying buffer to transform into the final value, potentially returning more string than relates to the actual data of the Binary instance.

In general, you may not encounter this bug if Binary instances are created from a data source (new Binary(someBuffer)) or are returned by the database because in both of these cases binary.position is equal to the length of the underlying buffer.

Fixed example creating an empty Binary:

new BSON.Binary().toString();
// old output: '\x00\x00\x00\x00...' (256 zeros)
// new output: '' 

Experimental APIs

This release contains experimental APIs that are not suitable for production use. As a reminder, anything marked @experimental is not a part of the stable semantically versioned API and is subject to change in any subsequent release.

Bug Fixes


We invite you to try the bson library immediately, and report any issues to the NODE project.