Skip to content

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

Merged
autarch merged 2 commits into
mainfrom
10-30-fix_mongodb-runner_keep_server_logs_after_mongodb-runner_start_exits
Nov 4, 2026
Merged

autarch merged 2 commits 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 was 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

@autarch
autarch force-pushed the 10-30-fix_mongodb-runner_keep_server_logs_after_mongodb-runner_start_exits branch 2 times, most recently from a997544 to 41ae4cf Compare November 2, 2026 16:40
@autarch
autarch marked this pull request as ready for review November 2, 2026 16:43
@autarch
autarch requested review from a team as code owners November 2, 2026 16:43
@autarch
autarch requested review from alenakhineika and a balanced review from Copilot November 2, 2026 16:43
@codeowners-service-app

codeowners-service-app Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Assigned ivandevp for team compass-developers because alenakhineika is out of office.
Assigned mabaasit for team mongosh-developers because alenakhineika is out of office.

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.

🟢 Approval recommended

No active review issues remain for the persistent server logging changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@autarch autarch changed the title fix(mongodb-runner): keep server logs after mongodb-runner start exits fix(mongodb-runner): DRIVERS-3673 keep server logs after mongodb-runner start exits Nov 4, 2026

@lerouxb lerouxb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems fine. I don't think anything is going to maintain this CHANGELOG.md file, so it will keep saying whatever is there is unreleased. As for your other question it is probably OK as a follow-up?

@autarch

autarch commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Seems fine. I don't think anything is going to maintain this CHANGELOG.md file, so it will keep saying whatever is there is unreleased. As for your other question it is probably OK as a follow-up?

I removed this CHANGELOG.md file.

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 0c840bb to 6268147 Compare November 4, 2026 17:10
@autarch
autarch merged commit 2def386 into main Nov 4, 2026
19 checks passed
@autarch
autarch deleted the 10-30-fix_mongodb-runner_keep_server_logs_after_mongodb-runner_start_exits branch November 4, 2026 19:23
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