This is a simplified version of the problem, but basically I\'m trying to open 2 mongodb connections with mongoose and it\'s giving me \"Trying to open unclosed connection.\
Using mongoose.disconnect(fn):
mongoose.disconnect(() => {
// here it would be possible "reset" models to fix
// OverwriteModelError errors
mongoose.models = {};
// here comes your logic like registering Hapi plugins
server.register(somePlugin, callback);
});
I found this question typing the error message and despite my problem is a bit different I believe it could be useful for those using Hapi. More specifically Hapi + rest-hapi + mocha.
When running mocha
with --watch
option I was facing both: OverwriteModelError
and Error: Trying to open unclosed connection errors
.