-
Notifications
You must be signed in to change notification settings - Fork 179
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
App hang when using promises/async on connecting #258
Comments
I ran into this problem yesterday as well and have tried all manner of things. I'm not sure if the
However, if mongo isn't actually running when It would be great if this problem could get fixed, because I'm trying to use |
Monk constructor is indeed not returning a promise at all. It's returning a function that vaguely looks like a promise. Not only that: the promise is also not resolving to the monk instance, so you can't do I would strongly encourage monk's maintainer to either make A hack meanwhile:
If I could also request JS developers everywhere to stop returning type-punned results that look like many different things, and instead be a single value, I'd be very happy :( |
Happy to accept a PR |
Sorry for my tone. Had a really bad day. Working on a PR. |
I just want to note that the hack above is creating two connections actually, but we are not getting the second connection instance back, so it's impossible to close (causing the Node process to stay alive even if all the operations are done). |
A year later, this is still a problem, and I don't think there's a solution that doesn't break compatibility. The only workaround I've been able to use is: function connect (uri) {
const db = monk(uri);
db.then = null;
return new Promise((accept, reject) => {
db.once('open', () => accept(db));
db.once('error-opening', reject);
});
} Essentially, remove the |
I'm using
NodeJS 8.11.3
withMonk 6.0.6
and I have the next piece of code:I have tried in so many ways to make this works( using the callback from
monk(url)
, making the functionasync
and callingawait
on monk, and so many methods) and the code just freeze/hang and nothing happen and I don't know how to resolve it. Please some help.The text was updated successfully, but these errors were encountered: