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(model): avoid hanging on empty bulkWrite() with ordered: false #13684

Merged
merged 1 commit into from Aug 3, 2023

Conversation

vkarpov15
Copy link
Collaborator

Fix #13664

Summary

Looks like if bulkWrite() is empty and ordered: false, we never hit the if (--remaining <= 0) check, so bulkWrite() hangs forever. Fixed in this PR, but likely worth doing some refactoring to switch to using async functions rather than callbacks internally within bulkWrite() to avoid this sort of issue.

Examples

Copy link
Collaborator

@IslandRhythms IslandRhythms left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

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

Nice! Keen to assist with any refactoring from callbacks to async/await. It's sort of a meditation for me. 😃

@JavaScriptBach
Copy link
Contributor

Thanks for the fix!

@vkarpov15 vkarpov15 merged commit 9cb950d into master Aug 3, 2023
34 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-13664 branch August 4, 2023 08:46
JavaScriptBach added a commit to JavaScriptBach/mongoose that referenced this pull request Aug 4, 2023
vkarpov15 added a commit that referenced this pull request Aug 6, 2023
Backport empty bulkwrite fix #13684 to Mongoose v6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Model.bulkWrite() hangs forever when run on an empty list and ordered: false
5 participants