Skip to content

fix(mongodb-runner): keep server logs after mongodb-runner start exits - #946

Draft
autarch wants to merge 1 commit into
mainfrom
10-30-fix_mongodb-runner_keep_server_logs_after_mongodb-runner_start_exits
Draft

autarch wants to merge 1 commit into
mainfrom
10-30-fix_mongodb-runner_keep_server_logs_after_mongodb-runner_start_exits

Conversation

@autarch

@autarch autarch commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

With --logDir set, each server's stdout and stderr were piped through the runner process into the log file. mongodb-runner start exits once the cluster is up, so nothing wrote to those files afterward and every log ended at startup.

This redirects the server's stdout and stderr straight to the log file instead, so the server keeps logging on its own. The runner follows the file to read the startup output (port and build info) that it previously got from the pipe.

Log files are now named <binary>-<uuid>-<timestamp>.log rather than using the pid, since the pid isn't known before the file has to exist.

stderr now shares the file the runner parses, so lines that aren't log entries (for example docker's "Unable to find image") are skipped instead of ending the log stream and failing startup.

Open Questions

  • We could take this further. Right now, if a user attempts to set --logpath for the Server, the runner is broken because it can't find the logs to tail to get the Server's port and build info. Do you want me to add this to this PR? A follow-up? Not at all?
  • This PR adds a CHANGELOG.md file for mongodb-runner. Is that ok?

Checklist

Copilot AI balanced review requested due to automatic review settings October 30, 2026 19:36
@autarch
autarch force-pushed the 10-30-fix_mongodb-runner_keep_server_logs_after_mongodb-runner_start_exits branch from d5008f4 to 46e35ea Compare October 30, 2026 19:37

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.

🟡 Changes recommended

An unref’d tail timer can let Node exit before draining final output or signaling EOF, causing failed server startup with --logDir to silently exit successfully instead of reporting an error.

1 open issue
What changed in this PR

This PR keeps MongoDB server logs flowing after mongodb-runner start exits by letting servers write directly to log files while the runner tails them for startup information.

Changes:

  • Redirect server stdout and stderr to UUID-based log files.
  • Add file tailing and skip non-log lines during parsing.
  • Add tests for tailing, parsing, and continued logging after CLI exit.
File Description
packages/​mongodb-runner/​src/​tail-file.ts Adds polling-based file tailing until server exit.
packages/​mongodb-runner/​src/​tail-file.spec.ts Tests appended output and draining after exit.
packages/​mongodb-runner/​src/​mongoserver.ts Redirects server output directly to files and tails startup logs.
packages/​mongodb-runner/​src/​mongologreader.ts Skips non-log lines instead of ending parsing.
packages/​mongodb-runner/​src/​mongologreader.spec.ts Tests parsing past non-log output.
packages/​mongodb-runner/​src/​cli.spec.ts Tests continued logging after start exits.

Review effort: Balanced

With `--logDir` set, each server's stdout and stderr were piped through the runner process into the
log file. `mongodb-runner start` exits once the cluster is up, so nothing wrote to those files
afterward and every log ended at startup.

This redirects the server's stdout and stderr straight to the log file instead, so the server keeps
logging on its own. The runner follows the file to read the startup output (port and build info)
that it previously got from the pipe.

Log files are now named `<binary>-<uuid>-<timestamp>.log` rather than using the pid, since the pid
isn't known before the file has to exist.

stderr now shares the file the runner parses, so lines that aren't log entries (for example docker's
"Unable to find image") are skipped instead of ending the log stream and failing startup.
@autarch
autarch force-pushed the 10-30-fix_mongodb-runner_keep_server_logs_after_mongodb-runner_start_exits branch from 46e35ea to a997544 Compare October 30, 2026 19:52
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.

2 participants