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-3442): AsyncIterator has incorrect return type #2916

Merged
merged 3 commits into from Jul 21, 2021

Conversation

nbbeeken
Copy link
Contributor

The AsyncIterator had TSchema or null as its return type the truth is that the for await loop ends when the next function returns null so you never get null in your loop.

Comment on lines +43 to +44
return executeLegacyOperation(topology, operation, [{}, null], options).then(null, err => {
expect(err).to.equal(expectedError);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was failing on the first commit I pushed, might have been flaky and I coulda tried a rerun but changing this to not rely on a setTimeout seems like a quick cleanup win.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cleaning up flaky tests is always good in my book! 👍

@@ -2,6 +2,7 @@

const { expect } = require('chai');
const Sinon = require('sinon');
const { Promise: BluebirdPromise } = require('bluebird');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I brought in bluebird because our current test just did class P extends Promise and I needed something that wouldn't extend the native promise.

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM, I think it's a good idea to test bluebird anyway, since it's the most likely alternative promise library people would use.

Comment on lines 228 to 229
if (value !== null && value !== undefined) return { value, done: false };
return { value: undefined, done: true };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can totally ternary this, thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

The ternary was nice and succinct, do you prefer it this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I spread it out for debugging but just now thought I can clean it up, changed it, looks v neat now :)

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

Comment on lines 228 to 229
if (value !== null && value !== undefined) return { value, done: false };
return { value: undefined, done: true };
Copy link
Contributor

Choose a reason for hiding this comment

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

The ternary was nice and succinct, do you prefer it this way?

@@ -2,6 +2,7 @@

const { expect } = require('chai');
const Sinon = require('sinon');
const { Promise: BluebirdPromise } = require('bluebird');
Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM, I think it's a good idea to test bluebird anyway, since it's the most likely alternative promise library people would use.

Comment on lines +43 to +44
return executeLegacyOperation(topology, operation, [{}, null], options).then(null, err => {
expect(err).to.equal(expectedError);
Copy link
Contributor

Choose a reason for hiding this comment

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

Cleaning up flaky tests is always good in my book! 👍

@emadum emadum added the Team Review Needs review from team label Jul 21, 2021
@emadum emadum requested a review from dariakp July 21, 2021 21:00
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

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

LGTM :)

@emadum emadum merged commit 4a10389 into 4.0 Jul 21, 2021
@emadum emadum deleted the NODE-3442/async-iter-types branch July 21, 2021 23:48
@nbbeeken
Copy link
Contributor Author

nbbeeken commented Aug 5, 2021

Hey @adityapatadia that sounds like a pretty bad bug, could you open a ticket on our JIRA describing the steps to reproduce?

@adityapatadia
Copy link
Contributor

Apologies for wrong flag. When we use newly released v7.0 of snappy library, none of the queries work. I downgraded snappy and everything works fine.

@nbbeeken
Copy link
Contributor Author

nbbeeken commented Aug 5, 2021

Funny you mention it! I identified a bug with the new Snappy lib just hours ago, for now the driver can only use snappy 6.x but we plan to add a fix to support either soon. Keep an eye on the release notes for the fix or follow this ticket: https://jira.mongodb.org/browse/NODE-3528

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
4 participants