Repository navigation
Conversation
autarch
force-pushed
the
10-30-fix_mongodb-runner_keep_server_logs_after_mongodb-runner_start_exits
branch
from
October 30, 2026 19:37
d5008f4 to
46e35ea
Compare
Contributor
There was a problem hiding this comment.
🟡 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
force-pushed
the
10-30-fix_mongodb-runner_keep_server_logs_after_mongodb-runner_start_exits
branch
from
October 30, 2026 19:52
46e35ea to
a997544
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
With
--logDirset, each server's stdout and stderr were piped through the runner process into the log file.mongodb-runner startexits 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>.lograther 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
--logpathfor 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?CHANGELOG.mdfile for mongodb-runner. Is that ok?Checklist