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-2035): exceptions thrown from awaited cursor forEach do not propagate #2835

Conversation

W-A-James
Copy link
Contributor

@W-A-James W-A-James commented Jun 10, 2021

Description

Catch and propagate exceptions in awaited cursor.forEach

What changed?

  • src/cursor/abstract_cursor.ts
  • test/functional/cursor.js

@W-A-James W-A-James requested a review from nbbeeken June 10, 2021 19:29
@nbbeeken nbbeeken changed the title Node 2035/4.0/exceptions thrown from awaited cursor for each do not propagate fix(NODE-2035): exceptions thrown from awaited cursor for each do not propagate Jun 10, 2021
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

Nice job finding the fix, some clean up and its looking pretty much ready

src/cursor/abstract_cursor.ts Outdated Show resolved Hide resolved
src/cursor/abstract_cursor.ts Outdated Show resolved Hide resolved
test/functional/cursor.test.js Outdated Show resolved Hide resolved
test/functional/cursor.test.js Outdated Show resolved Hide resolved
@nbbeeken nbbeeken marked this pull request as draft June 14, 2021 14:49
@W-A-James W-A-James requested a review from nbbeeken June 14, 2021 16:32
test/functional/cursor.test.js Outdated Show resolved Hide resolved
test/functional/cursor.test.js Outdated Show resolved Hide resolved
@W-A-James W-A-James requested a review from nbbeeken June 15, 2021 16:07
@W-A-James W-A-James marked this pull request as ready for review June 15, 2021 16:26
@nbbeeken nbbeeken requested review from a team, durran, dariakp and emadum and removed request for a team June 15, 2021 18:34
@nbbeeken nbbeeken added the Team Review Needs review from team label Jun 15, 2021
@emadum emadum changed the title fix(NODE-2035): exceptions thrown from awaited cursor for each do not propagate fix(NODE-2035): exceptions thrown from awaited cursor forEach do not propagate Jun 15, 2021
src/cursor/abstract_cursor.ts Outdated Show resolved Hide resolved
src/cursor/abstract_cursor.ts Outdated Show resolved Hide resolved
test/functional/cursor.test.js Outdated Show resolved Hide resolved
@W-A-James W-A-James requested a review from dariakp June 15, 2021 20:58
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.

Nice work!

In addition to the changes in the afterEach hook, I think the test's readability would be improved by being rewritten using async/await instead of Promise syntax, now that it's available to use in driver v4. Totally up to you whether to do that though, the test LGTM otherwise.

test/functional/cursor.test.js Outdated Show resolved Hide resolved
@W-A-James W-A-James requested a review from emadum June 16, 2021 17:48
test/functional/cursor.test.js Outdated Show resolved Hide resolved
@W-A-James W-A-James requested a review from dariakp June 16, 2021 21:16
test/functional/cursor.test.js Outdated Show resolved Hide resolved
@W-A-James W-A-James force-pushed the NODE-2035/4.0/Exceptions-thrown-from-awaited-cursor-forEach-do-not-propagate branch from 70959d9 to f19b463 Compare June 17, 2021 14:19
@W-A-James
Copy link
Contributor Author

Rebased onto 4.0

@W-A-James W-A-James requested a review from dariakp June 17, 2021 14:23
expect.fail('Error in forEach call not caught');
})
.catch(err => {
console.log(err.message);
Copy link
Contributor

Choose a reason for hiding this comment

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

extra console log, otherwise LGTM :)

@W-A-James W-A-James requested a review from dariakp June 17, 2021 18:11
@nbbeeken nbbeeken merged commit ac49df6 into 4.0 Jun 17, 2021
@nbbeeken nbbeeken deleted the NODE-2035/4.0/Exceptions-thrown-from-awaited-cursor-forEach-do-not-propagate branch June 17, 2021 22:04
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
5 participants