Skip to content

fix(db): retry initial Mongo connection to avoid worker crash-loop#559

Open
Kuchizu wants to merge 5 commits into
masterfrom
fix/mongo-connect-retry
Open

fix(db): retry initial Mongo connection to avoid worker crash-loop#559
Kuchizu wants to merge 5 commits into
masterfrom
fix/mongo-connect-retry

Conversation

@Kuchizu

@Kuchizu Kuchizu commented Jun 3, 2026

Copy link
Copy Markdown
Member

DatabaseController.connect() now retries the initial handshake instead of throwing on the first failure.

@neSpecc neSpecc requested a review from Copilot June 4, 2026 19:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the MongoDB DatabaseController.connect() startup behavior so workers don’t crash-loop when MongoDB is temporarily unreachable, by retrying the initial connection handshake with a fixed delay and a bounded server-selection timeout.

Changes:

  • Add configurable retry loop for the initial MongoDB connection attempt (MONGO_RECONNECT_TRIES, MONGO_RECONNECT_INTERVAL).
  • Add serverSelectionTimeoutMS to ensure each attempt fails fast during outages.
  • Adjust connect() to return the existing Db instance when already connected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/db/controller.ts Outdated
Comment thread lib/db/controller.ts Outdated
Comment thread lib/db/controller.ts
neSpecc
neSpecc previously approved these changes Jun 10, 2026
Comment thread lib/db/controller.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants