diff --git a/package-lock.json b/package-lock.json index d9d818f0af1..8b0b2db2b57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1402,9 +1402,9 @@ } }, "hooks-fixed": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-2.0.0.tgz", - "integrity": "sha1-oB2JTVKsf2WZu7H2PfycQR33DLo=" + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-2.0.2.tgz", + "integrity": "sha512-YurCM4gQSetcrhwEtpQHhQ4M7Zo7poNGqY4kQGeBS6eZtOcT3tnNs01ThFa0jYBByAiYt1MjMjP/YApG0EnAvQ==" }, "http-errors": { "version": "1.6.2", diff --git a/package.json b/package.json index 6e84144fbae..55f7e69bb87 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "dependencies": { "async": "2.1.4", "bson": "~1.0.4", - "hooks-fixed": "2.0.0", + "hooks-fixed": "2.0.2", "kareem": "1.5.0", "mongodb": "2.2.33", "mpath": "0.3.0", diff --git a/test/document.hooks.test.js b/test/document.hooks.test.js index c73ff0ccd6c..6c47abdb2a3 100644 --- a/test/document.hooks.test.js +++ b/test/document.hooks.test.js @@ -763,6 +763,26 @@ describe('document: hooks:', function() { done(); }); + it('sync exceptions get passed as errors (gh-5738)', function(done) { + var bookSchema = new Schema({ title: String }); + + /* eslint-disable no-unused-vars */ + bookSchema.pre('save', function(next) { + throw new Error('woops!'); + }); + + var Book = mongoose.model('gh5738', bookSchema); + + var book = new Book({}); + + book.title = 'Professional AngularJS'; + book.save(function(error) { + assert.ok(error); + assert.equal(error.message, 'woops!'); + done(); + }); + }); + it('nested subdocs only fire once (gh-3281)', function(done) { var L3Schema = new Schema({ title: String