nswbmw / koa-mongo

MongoDB middleware for koa, support connection pool.
145 stars 31 forks source link

Fix for generic pool swallowing mongo client connection errors #36

Closed South-Paw closed 5 years ago

South-Paw commented 5 years ago

Hey, thought I'd do my part and contribute in what I found.

While using this library I noticed that on creation of mongo connections, if they error'd they would have their errors swallowed and you wouldn't be aware to this happening (e.g. auth failed and failed to connect etc).

I saw that #33 tried to do something similar but as @nswbmw said, you can't throw an error from the callback ... but this is because generic pool swallows it.

In generic-pool, when the create method is called a factory object is passed - if that factory returns an Error then the pool will throw the error for us and thus stop our koa server and make us aware somethings gone wrong.

Hope this makes sense, thanks for the middleware. 👍

nswbmw commented 5 years ago

@South-Paw Thanks!