Skip to content

test(mcp): capture debug logs around cli show / connectToDashboard (do-not-merge)#40703

Draft
Skn0tt wants to merge 7 commits intomicrosoft:mainfrom
Skn0tt:log-daemon
Draft

test(mcp): capture debug logs around cli show / connectToDashboard (do-not-merge)#40703
Skn0tt wants to merge 7 commits intomicrosoft:mainfrom
Skn0tt:log-daemon

Conversation

@Skn0tt
Copy link
Copy Markdown
Member

@Skn0tt Skn0tt commented May 7, 2026

Spec branch to flush out flakiness around cli show and connectToDashboard in dashboard/annotate tests.

Do not merge — diagnostic branch only.

Skn0tt added 4 commits May 7, 2026 15:41
Adds an opt-in (`PWTEST_CLI_LOG_DIR`) facility for redirecting the
detached `cli show` daemon's stdout/stderr to per-spawn log files, and
turns it on for every test in `tests/mcp/cli-fixtures.ts` together with
`DEBUG=pw:*`. The cli fixture's teardown now surfaces every file from
`cli-logs/`, `daemon/`, and `registry/` as a test attachment on every
run (pass or fail), so we can diff a passing run against a flaky one
when chasing dashboard / connectToDashboard timeouts. Empty files are
rewritten with `<empty>` before attaching so they show up in
`attachments/` and "no output" is distinguishable from "missing".
The previous change unconditionally routed the spawned dashboard
daemon's stdio through `daemonStdio()` when `PWTEST_CLI_LOG_DIR` is
set. In foreground mode (`--port=0`) the test fixture
`startDashboardServer` waits for "Listening on ..." on the CLI's
stdout — redirecting to a file makes that marker never arrive, so
every test that calls `startDashboardServer()` times out at 30s.
Only redirect to log files when the daemon is detached.
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

cli show spawns the dashboard daemon detached and previously returned
immediately. Callers (tests, scripts) had no way to know when the
dashboard was actually usable, leading to races - e.g. on slow Windows
CI where Chrome cold-launch takes ~26s, the registry entry appears
well before the dashboard page finishes navigating.

Add a fourth 'pipe' stdio entry (fd 3) so the detached daemon can
signal READY back to the parent once the dashboard server is
listening, the browser is launched and bound, and page.goto has
completed. Parent waits up to 60s, destroys its read end so Windows
reaps the pipe handle, then unref()s and returns.

The child's write is wrapped in try/catch to tolerate EPIPE (parent
closed early on timeout) and the developer-debug case of running
node dashboardApp.js directly.
@github-actions

This comment has been minimized.

Skn0tt added 2 commits May 8, 2026 09:43
Makes the report/trace show which CLI call was in flight when a test
timed out, instead of just "Test timeout of 30000ms exceeded".
CI evidence on this branch shows all remaining MCP flakes are Windows-only
budget exhaustion: Chrome cold-launch can eat the full 30s test budget on
win-chrome, and the dashboard React mount sometimes pushes past the default
5s expect timeout. Linux and macOS runs were fully green, so keep them tight
to fail fast on genuine regressions.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Test results for "MCP"

7031 passed, 1068 skipped


Merge workflow run.

@Skn0tt
Copy link
Copy Markdown
Member Author

Skn0tt commented May 8, 2026

wow, that helped

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.

1 participant