mongo-in-memory icon indicating copy to clipboard operation
mongo-in-memory copied to clipboard

Issue with UnhandledPromiseRejectionWarning: Unhandled promise rejection

Open AlirezaAtGeeks opened this issue 7 years ago • 3 comments

Could you please update line 160 with

collection.insertOne(document, function (error, result) { if (error) { reject(error); } else if (result.n === 0) { reject(new Error("no document was actually saved in the database")); } else { resolve(result.ops[0]); } });

Also when I run mocha in recursive mode, it's complaining about UnhandledPromiseRejectionWarning: Unhandled promise rejection. What do you suggest?

AlirezaAtGeeks avatar Oct 05 '17 11:10 AlirezaAtGeeks

@AlirezaAtGeeks could you create a Pull Request for me to approve? How to create a Pull Request tutorial

The unhandled promise rejection I think is something you have to manage in your code either by adding a .catch or with process.on('unhandledRejection', error => { console.log('unhandledRejection', error.message); }); Unhandled Promise Rejections in Node.js

giorgio-zamparelli avatar Oct 05 '17 11:10 giorgio-zamparelli

It seems I don't have permission to push my changes If you think that is not necessary, I can ignore it. However, I wanted to follow the addDocument procedure for handling it.

AlirezaAtGeeks avatar Oct 05 '17 12:10 AlirezaAtGeeks

Yes it's supposed to be that way. Its a Pull Request not a Push changes! :) Read the tutorial and/or Google it!

giorgio-zamparelli avatar Oct 05 '17 14:10 giorgio-zamparelli