chore(main): release 6.0.0 [skip-ci] #596
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🌱 A new release!
6.0.0 (2023-08-24)
The MongoDB Node.js team is pleased to announce version 6.0.0 of the
bsonpackage!Release Notes
In this major version update, we focused on removing deprecated or otherwise difficult to use APIs and fixing impactful bugs.
Important
The
BSON_MAJOR_VERSIONhas been bumped to 6. Only BSON objects that have this major version can be serialized with this version of the library. Mismatched objects will throw aBSONVersionErrorwhen attempting to serialize.Important
The minimum supported Node.js version is now v16.20.1. We strive to keep our minimum supported Node.js version in sync with the runtime's release cadence to keep up with the latest security updates and modern language features.
Decimal128constructor now throws when detecting loss of precisionPrior to this release,
Decimal128would round numbers with more than 34 significant digits and lose precision. Now, on detecting loss of precision,Decimal128's constructor andDecimal128.fromStringwill throw aBSONError. This behaviour should have been the default as theDecimal128class was always intended to be high-precision floating point value. As such, silently rounding is undesirable behaviour as it can potentially result in data loss.Note a separate method with corrected rounding behaviour will be available in the next minor version of this library. Additionally a fix for this bug and the aforementioned new method with corrected rounding will be added in the next minor release of v5 of this library.
Strings of length 12 can no longer make an ObjectId
The
ObjectIdconstructor erroneously interpreted a string with length of 12 as UTF8 bytes that could be converted to an ObjectId. This is unexpected for at least two reasons. The first is that a legacy approach (pre- Uint8Arrays) to handling binary data was to pass around "binary strings", where each character represents a single byte, this is not the same as interpreting a sting as UTF8, which has restrictions on how each byte can be formatted. The second is that a string of length 12 does not result in 12 bytes of data when converted to utf8 (ex.'🐶🐶🐶🐶🐶🐶'.length === 12, but as UTF8 bytes this is a 24-byte sequence).Despite the bugginess of the behavior discussed above, the right string in the right context does create the proper byte sequence, so we are considering this a breaking change and removing it in this major release.
Removed ISO-8859-1 string format from
Binary(a.k.a'latin1','binary')The
BinaryBSON type no longer accepts a string as a constructor argument nor canwrite()be invoked with a string argument. Both methods interpreted strings as binary sequences rather than UTF-8 or base64 which are much more common and expected formats. If there is a string representation of your data it is now expected that the logic that interprets the string format exists outside the Binary class to avoid misinterpreting data. Additionally,.value()only returns aUint8Array/Bufferthat is properly sized to the data. InternallyBinarymay maintain a.bufferproperty larger than the the actual data that will be written to BSON bytes. Use.value()to obtain only the bytes relevant to yourBinarydata.ObjectId.equalsnow acceptsundefinedandnullparametersThanks to @vanstinator for providing this pull request fixing our
ObjectId.equalssignature to properly allow checking equality with nullish values.Removed deprecated
UUID.cacheHexStringpropertyThis property was unused and so was removed.
⚠ BREAKING CHANGES
Bug Fixes
Documentation
We invite you to try the
bsonlibrary immediately, and report any issues to the NODE project.