-
-
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
feedback: tool should return an error in its callback if not connected to Mongo #3698
Comments
Turn off the bufferCommands option if you don't like this behavior. |
I don't think that really addresses my issue. Why would it be buffering a command if there is only one command? The whole point is that there is something that the tool needs to happen before it can work. That thing did not happen. The tool simply ignored it and did not return an error. It should return an error when the query is executed if there are no connections present. Silently failing is always the wrong choice. |
The point is that it isn't a failure, silent or otherwise, if buffering is on. The point of buffering is that you don't have to wait for a connection to be established to start using your models, nor do you have to worry about connection interruptions. |
If the tool never connects to the database, the tool just seems to shrug and ignore it. I see what you are saying but you should put a timeout on that initial connection -- if it doesn't connect within 60 seconds (configurable), emit an error of some sort. Buffering is fine but in this situation the tool appears to be doing nothing and be totally ok with that. What if my database URL is wrong, will mongoose just ignore that too? Seems like it might. |
You'll get an error on the connection if your database URL is wrong, but if buffering is on then mongoose will happily buffer operations until you successfully connect. It's meant as some syntactic sugar so you don't have to wait for a connection to be established before doing database operations - if you don't like it, turn it off. |
And again I have to say: silently failing is always the wrong choice. How would I know to turn off something that is on by default and never results in an error? Again, this is terrible UX. I've offered a suggestion for fixing it. Your answer seems to be that it's fine as it is. |
You make a fair argument, I admit to having been caught by this a couple times as well. There may be a better way to do this, we'll take a look for future releases. However, this behavior can't change by default without bumping 5.0. |
We have |
JS:
Output:
I suspect that I'm not connected to the database and that's why I'm not getting any output. That's bad UX though -- if the tool needs me to do X then Y before running a query but I fail to do Y, the tool should tell me that I didn't do Y (or at least try to). As it is, the tool is silently failing.
The text was updated successfully, but these errors were encountered: