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

fix(NODE-3528): add support for snappy v7 #2947

Merged
merged 4 commits into from Aug 25, 2021
Merged

fix(NODE-3528): add support for snappy v7 #2947

merged 4 commits into from Aug 25, 2021

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Aug 24, 2021

Not a straight port, see comments

@nbbeeken nbbeeken marked this pull request as ready for review August 25, 2021 14:04
@nbbeeken nbbeeken added the Team Review Needs review from team label Aug 25, 2021
Comment on lines 25 to 28
if (bsonExtVersion.major >= 4) {
emitWarningOnce(
'bson-ext version 4 and above does not work with the 3.x version of the mongodb driver'
);
Copy link
Contributor Author

@nbbeeken nbbeeken Aug 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I added the version parsing logic I figured we could add a check here to warn folks, we could also throw here, but the driver will crash elsewhere anyway "bson is not a constructor" is likely the first error to be hit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be more helpful to throw here with the appropriate error instead of letting it fail in a weird way down the line? also, why not put the code doing the check in the if (optionalBSON) block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it, and I tested this, it throws at the moment of require('mongodb') so it'll stop scripts right up front.

if (version.major >= 7) {
const compressOriginal = snappy.compress;
const uncompressOriginal = snappy.uncompress;
snappy.compress = (data, callback) => {
Copy link
Contributor Author

@nbbeeken nbbeeken Aug 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly different approach taken, just wrap the functions here, the actual usage site needs no changes now.

SINGLETON_TASKS.push({
name: 'run-custom-csfle-tests',
tags: ['run-custom-csfle-tests'],
const oneOffFuncs = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ported over the CI changes, I actually took a stab at bringing in the bson-ext CI here too, but it started having too much overhead for this PR, but this sets us up to have easier one-off targets going forward.

Copy link
Contributor

@emadum emadum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one stylistic suggestion.

Comment on lines 476 to 479
fileData.tasks = (fileData.tasks || [])
.concat(BASE_TASKS)
.concat(TASKS)
.concat(SINGLETON_TASKS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fileData.tasks = (fileData.tasks || [])
.concat(BASE_TASKS)
.concat(TASKS)
.concat(SINGLETON_TASKS);
fileData.tasks = (fileData.tasks || []).concat(BASE_TASKS, TASKS, SINGLETON_TASKS);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done! did it locally along with prettier just to make sure the formatting is right

@dariakp dariakp merged commit 54f5c2d into 3.6 Aug 25, 2021
@dariakp dariakp deleted the NODE-3528/snappy-7 branch August 25, 2021 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
3 participants