Skip to content
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

Make connection errors catchable #400

Open
jespertheend opened this issue Sep 18, 2023 · 0 comments · May be fixed by #401
Open

Make connection errors catchable #400

jespertheend opened this issue Sep 18, 2023 · 0 comments · May be fixed by #401

Comments

@jespertheend
Copy link

Sometimes our database server restarts, which causes all clients using get disconnected. We have a whole bunch of servers which all talk to the same database, so I have to manually restart all of these to get them to reconnect again.

Making a MongoClient automatically reconnect closed connections would be nice, but would probably require a lot of work and might be out of scope for this project.

Instead, I'm fine with handling this myself, but the problem is that may calls result in an unhandled rejection being thrown that you can't easily catch.

Specifically Protocol.ts receive() seems to be generating a bunch of unhandled rejections. Sometimes I'm getting "Invalid response header". Other times this.#reader.readFull rejects with "Connection reset by peer".

I can reliably reproduce this by simply restarting mongod:
brew services restart mongodb-community

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant