Skip to content

fix: MongoDB waitForReady falls back to TCP when auth rejects mongosh#160

Merged
robertjbass merged 1 commit intomainfrom
dev
Apr 1, 2026
Merged

fix: MongoDB waitForReady falls back to TCP when auth rejects mongosh#160
robertjbass merged 1 commit intomainfrom
dev

Conversation

@robertjbass
Copy link
Copy Markdown
Owner

@robertjbass robertjbass commented Apr 1, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved MongoDB readiness probe handling for authentication-enabled instances with a TCP connectivity fallback.
  • Chores

    • Version bump to 0.47.13.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

📝 Walkthrough

Walkthrough

Version 0.47.13 adds a fallback recovery mechanism to MongoDB's readiness probe. When mongosh authentication fails, the health check now attempts a TCP port availability check instead of waiting for retry, improving readiness detection for auth-enabled MongoDB instances.

Changes

Cohort / File(s) Summary
Version Bump
package.json
Updated package version from 0.47.12 to 0.47.13.
Readiness Probe Enhancement
engines/mongodb/index.ts
Added TCP port fallback in waitForReady(): when mongosh ping fails (e.g., auth error), the probe now checks port availability via checkPortOpen(port) and returns immediately if the port is open, bypassing retry delays.
Changelog Documentation
CHANGELOG.md
Added 0.47.13 release notes documenting the MongoDB auth-tolerant readiness check fix and PID tracking improvement.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A mongosh auth guard appears,
When passwords block the way,
TCP port knocks without tears—
"The MongoDB's here to stay!"
Fallback paths both wise and clear,
Keep the readiness on track. 🚀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: MongoDB's waitForReady now falls back to TCP port checking when mongosh authentication fails, which is directly reflected in both CHANGELOG.md and engines/mongodb/index.ts modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@engines/mongodb/index.ts`:
- Around line 596-601: The catch currently treats all mongosh failures as auth
and falls back to TCP; change it to capture the thrown error and only perform
the TCP fallback when the error message or code matches auth-related signatures
(e.g., /auth|authentication|not authorized|Unauthorized/i or known mongosh auth
exit codes); for any other error rethrow or continue the health retry loop so we
don't report ready when mongod is unhealthy. Locate the try/catch around the
mongosh health check and update it to inspect the caught error before calling
this.checkPortOpen(port) (referenced symbol: checkPortOpen) and only return true
on TCP fallback when the error matches the auth-specific checks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 38779bc2-60ab-44c8-a7a0-5920602c170b

📥 Commits

Reviewing files that changed from the base of the PR and between bf72b09 and 9df9040.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • engines/mongodb/index.ts
  • package.json

@robertjbass robertjbass merged commit 9990d48 into main Apr 1, 2026
267 of 270 checks passed
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 this pull request may close these issues.

1 participant