-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.save() throws expection when using with co / koajs #2371
Comments
Thanks for pointing this out, I'll investigate. |
I have same issue .... with normal callback from save .... No listeners detected, throwing. Consider adding an error listener to your connection. |
I am able to reproduce this issue in v3.9.7 mongoose test on the ES6 $ MONGOOSE_DISABLE_STABILITY_WARNING=1 ./node_modules/.bin/mocha --harmony --grep "Documents in ES6 validate()" test/harmony The test would fail with db = start({ noErrorListener: 1 }); However, if I add a model level error listener to the test case that does nothing, the test passes: M.on('error', function(){}); |
I also encounter this issue where the exception still get past the try catch around save() function and crash the process. Like justin-lau mentioned above, the model level error listener does not catch that exception. The exception in my case was thrown in my custom validation function. |
Thanks @justin-lau, debugged it for me :) looks like its tricky to determine if there are listeners or not when using yield, so I'm just gonna get rid of that exception. |
Hi,
I use the latest master release in my koajs project and I encountered some strange issue:
In my tests im trying to actively save a User which will not pass validation. Mongoose then throws an error:
No listeners detected, throwing. Consider adding an error listener to your connection.
Even though I wrapped my
JavaScript yield userToSave.save()
statement in try-catch block the exception cannot be caught and therefore crashes my application 👎Isn't that contradictionary to the promise pattern? Shouldn't it simply call Promise.reject and not throw an exception on it's own?
The part in mongoose causing this (lib/document.js:1433):
Update: Even when using the classic callback approach, the exceptions gets thrown. That can't be right or can it be?
Best,
Michel
The text was updated successfully, but these errors were encountered: