deepkit / deepkit-framework

A new full-featured and high-performance TypeScript framework
https://deepkit.io/
MIT License
3.24k stars 123 forks source link

[mongo] don't throw on initial hosts connections #554

Open marcj opened 9 months ago

marcj commented 9 months ago

When multiple hosts are configured, currently it throws if only one is not available. This is wrong. It should only throw network related errors when all return an error and not a single needed host is available.

c5eda3d50b35f2b8ab5e868861dc/packages/mongo/src/client/connection.ts#L77

waitForAllConnectionsToConnect should not throw but just returns all catched errors.

ensureHostsConnected should only throw when throw=true and all hosts are down.

getConnection => ensureHostsConnected should catch the errors and throw only when no valid connection for the request can be found.