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
What is the current behavior?
pre-save hook silently swallows the exceptions when we don't pass callback to function but according to documentation it shouldn't be a problem: https://mongoosejs.com/docs/middleware.html#error-handling
If the current behavior is a bug, please provide the steps to reproduce.
const Schema = mongoose.Schema;
describe('PreSave', function () {
it('test pre save', async function () {
const TestScheme = new Schema({name: String});
TestScheme.pre('save', function () {
throw new Error('test err');
});
const TestModel = mongoose.model('testModel', TestScheme);
const testObject = new TestModel({name: 't'});
try {
await testObject.save();
} catch (e) {
// doesn't reach here!!
}
});
});
What is the expected behavior?
We must see the thrown error in catch section.
Node.js: 12.8.3
Mongoose: 5.11.4
MongoDB: 4.0.14
The text was updated successfully, but these errors were encountered:
vkarpov15
added
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
and removed
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
labels
Dec 8, 2020
vkarpov15
added a commit
to mongoosejs/kareem
that referenced
this issue
Dec 8, 2020
It's a bug
What is the current behavior?
pre-save hook silently swallows the exceptions when we don't pass callback to function but according to documentation it shouldn't be a problem: https://mongoosejs.com/docs/middleware.html#error-handling
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
We must see the thrown error in catch section.
Node.js: 12.8.3
Mongoose: 5.11.4
MongoDB: 4.0.14
The text was updated successfully, but these errors were encountered: