Skip to content

fix: use TCP socket health checks for database services#12142

Open
willtwilson wants to merge 4 commits intodanny-avila:mainfrom
willtwilson:fix/docker-tcp-health-checks
Open

fix: use TCP socket health checks for database services#12142
willtwilson wants to merge 4 commits intodanny-avila:mainfrom
willtwilson:fix/docker-tcp-health-checks

Conversation

@willtwilson
Copy link

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

  • docker-compose.yml: health checks for mongodb and vectordb; updated depends_on in api and rag_api
  • deploy-compose.yml: same changes for the production compose file
  • rag.yml: health check for vectordb; updated depends_on in rag_api

willtwilson and others added 2 commits March 8, 2026 21:39
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>
Copilot AI review requested due to automatic review settings March 8, 2026 21:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-based healthcheck to MongoDB (27017) and pgvector/Postgres (5432) services.
  • Update depends_on to use condition: service_healthy for services depending on these databases.
  • Adjust API depends_on formatting 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.

Comment on lines 31 to +33
depends_on:
- vectordb
vectordb:
condition: service_healthy
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

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
Copy link
Owner

Choose a reason for hiding this comment

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

this should be removed from PR

Copy link
Author

Choose a reason for hiding this comment

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

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>
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.

3 participants