Skip to content

Conversation

@Fonger
Copy link
Contributor

@Fonger Fonger commented Nov 20, 2019

Summary

Fix #8363. Correctly catch the error with callback when insertMany fails to initialize the document.
This can prevent DOS attack when inserting user-provided data.

This fix handles it like Model.create([...]) does.

Note: I've tested Model.bulkWrite() insertOne()/replaceOne() and I can confirm that it's not affected by this bug because $handleCallbackError wrap the entire bulkWrite callback handler and it catches the error during castBulkWrite().

However, in Model.insertMany(), parallelLimit() individual callbacks are not wrapped in that general handler (although $__insertMany is) so we need this fix.

Examples

See the test case

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

Thanks!

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.

insertMany() make node process to CRASH Unable to catch()

2 participants