You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I've encountered strange bug, when I added the mongoose-gridfs package to my project.
The uniqueErrorPlugin installs post hooks to every model I create. Everything works as expected when I use Model.save() method, but the Model.bulkSave() method starts to fail with this error:
TypeError: next is not a function
at model.handleUniqueError (/mongoose-bulksave-hooks-test/node_modules/@lykmapipo/mongoose-common/lib/index.js:132:14)
at next (/mongoose-bulksave-hooks-test/node_modules/kareem/index.js:238:35)
at next (/mongoose-bulksave-hooks-test/node_modules/kareem/index.js:261:9)
at next (/mongoose-bulksave-hooks-test/node_modules/kareem/index.js:230:16)
at Kareem.execPost (/mongoose-bulksave-hooks-test/node_modules/kareem/index.js:266:3)
at /mongoose-bulksave-hooks-test/node_modules/mongoose/lib/model.js:3747:29
at new Promise (<anonymous>)
at handleSuccessfulWrite (mongoose-bulksave-hooks-test/node_modules/mongoose/lib/model.js:3741:10)
at mongoose-bulksave-hooks-test/node_modules/mongoose/lib/model.js:3716:15
at Array.map (<anonymous>)
which is thrown by one of the hooks installed by the uniqueErrorPlugin.
I've created a repo with a test case reproducing the bug.
Using:
Node.js v18.10.0
NPM v8.19.2
mongoose v6.6.7
mongoose-gridfs v1.3.0
Do you have any tips on how to work around it, perhaps somehow not installing those hooks to every model?
Regards,
Alexandr
The text was updated successfully, but these errors were encountered:
Hello,
I've encountered strange bug, when I added the mongoose-gridfs package to my project.
The uniqueErrorPlugin installs post hooks to every model I create. Everything works as expected when I use
Model.save()
method, but theModel.bulkSave()
method starts to fail with this error:which is thrown by one of the hooks installed by the uniqueErrorPlugin.
I've created a repo with a test case reproducing the bug.
Using:
Node.js v18.10.0
NPM v8.19.2
mongoose v6.6.7
mongoose-gridfs v1.3.0
Do you have any tips on how to work around it, perhaps somehow not installing those hooks to every model?
Regards,
Alexandr
The text was updated successfully, but these errors were encountered: