fix: use TCP socket health checks for database services#12142
fix: use TCP socket health checks for database services#12142willtwilson wants to merge 4 commits intodanny-avila:mainfrom
Conversation
Documents the agent-browser MCP server which provides Playwright-backed browser automation for LibreChat agents via the Vercel agent-browser library. Key topics covered: - Why @ref accessibility snapshots beat raw CSS selectors for LLM agents - Tool reference table (navigate, snapshot, click, fill, get_text, etc.) - Docker Compose and build-from-source setup - librechat.yaml mcpServers configuration - Critical: why express.json() must NOT be used with MCP SSE transport - Session management and SSEServerTransport routing pattern - Zod-based tool registration pattern Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add bash /dev/tcp health checks to MongoDB (port 27017) and PostgreSQL/ pgvector (port 5432) services, which previously had no health checks. Update depends_on conditions so dependent services (rag_api, api) wait for their database dependencies to be healthy before starting. Files changed: docker-compose.yml, deploy-compose.yml, rag.yml Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds Docker Compose health checks for TCP-only database services so dependent containers (API/RAG) wait until databases are reachable, reducing startup race-condition failures.
Changes:
- Add
/dev/tcp-basedhealthcheckto MongoDB (27017) and pgvector/Postgres (5432) services. - Update
depends_onto usecondition: service_healthyfor services depending on these databases. - Adjust API
depends_onformatting to use conditional dependencies.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docker-compose.yml | Adds MongoDB/vectordb TCP healthchecks; updates depends_on conditions for api and rag_api. |
| deploy-compose.yml | Mirrors the same healthcheck + depends_on conditional startup behavior for production compose. |
| rag.yml | Adds vectordb TCP healthcheck and makes rag_api wait for vectordb to become healthy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| depends_on: | ||
| - vectordb | ||
| vectordb: | ||
| condition: service_healthy |
There was a problem hiding this comment.
rag.yml declares version: '3.8', but depends_on: { service: { condition: service_healthy } } is not supported in Compose file format v3.x by many Compose implementations (it was a v2.x feature and only works reliably with the newer Compose Specification when omitting version). This can make docker compose -f rag.yml up fail to parse/validate. Consider removing the version: key (preferred per current Compose spec) or switching to a v2.x version that supports depends_on.condition.
There was a problem hiding this comment.
Good catch — fixed in the follow-up commit (db4c71b). Removed version: '3.8' from rag.yml entirely. The depends_on.condition: service_healthy syntax is fully supported by the Compose Specification without a version key, which is now the recommended approach per Docker's own docs (https://docs.docker.com/compose/compose-file/). Added a brief inline comment explaining this.
depends_on with condition: service_healthy requires the Compose Specification format (Docker Compose v2+). The legacy version: '3.8' key may cause compatibility issues. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| @@ -0,0 +1,205 @@ | |||
| --- | |||
| title: Agent Browser MCP | |||
There was a problem hiding this comment.
this should be removed from PR
There was a problem hiding this comment.
You're right — that file was accidentally merged in from a separate docs branch. Removed in 265d82d.
The docs/docs/configuration/tools/agent-browser.mdx file was unintentionally included in this PR (merged from a separate branch). This PR is only for TCP health checks on database services. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Problem
The docker-compose files for LibreChat have no health checks on TCP-only database services (MongoDB port 27017, PostgreSQL/pgvector port 5432). Without health checks, dependent services like rag_api and api start immediately after their dependency containers launch -- before the database is actually ready to accept connections. This causes race-condition startup failures.
Solution
Add pure-bash /dev/tcp health checks to all TCP database services. This approach requires no external tools -- /dev/tcp is a bash built-in pseudo-device. Both mongo:8.0.17 and pgvector/pgvector:pg15-trixie are Debian-based and ship with bash.
The depends_on entries for services that depend on these databases are updated to use condition: service_healthy so Docker Compose waits for the health check to pass before starting the dependent service.
Files changed