Repository navigation
fix(core): fail runs when app commands exit after readiness - #1541
Conversation
|
Note 🤖 GPT-6.1 Sol responding on behalf of samanyudas PASS+NOTES. Independently ran the built real CLI with Chromium against main
Each case loaded the page in Chromium before requesting exit. Scope was one worker and one Chromium target on Linux. |
There was a problem hiding this comment.
All reported issues were addressed across 11 files
Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
Automated review by Claude Code on behalf of maintainers.
Thanks for the PR. The repro from #1532 now fails correctly, and the log tail is redacted. A few things need to change before merge.
Must fix
- An app exit during teardown fails a passing run. The process only stops being watched inside
stop()(managed-process.ts:425), andstop()runs last, after worker dispose andengines.finish(runner.ts:1135). If the app exits in that window, for example because engine dispose takes it down, it callsabortRun. Repro: a fake engine whoseonDisposemakes the app exit, plus one passing test. main exits 0. This branch exits 3 withAPP_UNREACHABLE ... after becoming ready, and the test showspassed. - One target's app exit aborts every target.
abortRunis the run-wide interrupt. Take targetsaandbwith separate commands: whena's app exits,b's running test is interrupted andb's queue is skipped, even thoughb's app is healthy. #1532 asks only for that target's remaining tests to stop. Please route the exit through the scheduler per target, the wayfailTarget/skipQueueshandleWORKER_START_FAILED. Give it a skip reason that names the app exit instead of "run interrupted before execution". A target with no queued or running work should ignore the exit, which also fixes item 1. Deduped commands serve several targets (declaredCommands), so the exit has to reach all of them. - Error code. We'd prefer a dedicated code (e.g.
APP_EXITED) over reusingAPP_UNREACHABLE. We'll confirm here, so please hold the docs until then.
Smaller
phasehas four states, but only=== 'running'is ever read. The'starting'reset instart()is dead, and'exited'is never read. Awatchingboolean is enough: true on ready, false instop().- Add tests for an exit during the readiness probe (
if (exit !== undefined) continue;) and for the!interrupted.abortedguard. The suite stays green with either one removed. Without the guard, Ctrl-C followed by an app exit reports 3 instead of 130. - Add JSDoc on
unexpectedExit, like its sibling hooks. fixtures.ts:463still suggests adding anapp.commandwhen the target already has one (mentioned in #1532).- Docs: please trim them to what users need. The 4-character redaction rule, the shared-log caveat and the spawn-error line are each repeated in three places, and the errors.mdx row is now very long.
- Changeset: "stop queued tests" should say which target's tests, once the scope is settled.
Mutations we ran: removing the hook call, the stopping phase, the running phase, or the runner hook is caught. Removing the readiness-probe continue or the !interrupted.aborted guard is not caught, and the 'starting' reset is dead code.
|
Note 🤖 GPT-6.1 Sol responding on behalf of samanyudas I reproduced the teardown failure with the built CLI. Main returns 0, while this head returns 3 after its only test passed. Please confirm |
|
Note 🤖 GPT-6.1 Sol responding on behalf of samanyudas Fixed the requested behavior in 1bb34eff.
The built CLI passed the 13 independent lifecycle scenarios and two watchdog-first cases for ordinary and serial work at
Ready for another review. |
There was a problem hiding this comment.
All reported issues were addressed across 21 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
Automated review by Claude Code on behalf of maintainers.
Thanks, this is much better. Teardown exits no longer fail a passing run, the exit now stops only the targets that depend on that command, and the skip reason names the exit. We checked the #1532 repro with the built CLI: a single target, two targets where the healthy one finishes, and an exit while test files load. All three exit 3 and the healthy target passes. The full e2e suite is green locally.
Must fix
- The app-exit branch of
failTarget(scheduler.ts:1131-1146) copies the per-worker body ofbroadcastInterrupt(scheduler.ts:530-543). It also walks the livethis.workersarray, wherebroadcastInterruptdeliberately copies it first. Please extract one helper (e.g.interruptWorker(worker, skip)) and use it in both places. - Please add an end-to-end test for a command that exits after readiness but before the scheduler starts (for example while test files load). Removing the delivery of
pendingAppFailuresatrunner.ts:1070leaves the suite green, and that window is where #1532 would come back.
Smaller
scheduler.ts:1034-1046: the hand-built interrupted attempt has the same shape ashungAttempt. A siblinginterruptedAttempt(active, index)would keep them together.scheduler.ts:494-496: move the pending check into a named helper. Thestate.unavailable?.kind === 'app-exit'skip at :493 can't trigger (one command per target, one exit per command), so it can go.scheduler.ts:501:?? failure.error.messageis dead, sincesplitalways returns at least one element.- The
receiveAppFailure/pendingAppFailures/ subscribe plumbing inrunner.tsis a hand-rolled event channel. Per-target AbortSignals (or a tiny buffered channel) would remove the mutable callback. - Could
appExitTargetsbe a boolean in the existing 130 filter (runner.ts:576) instead of a set returned from the scheduler and passed intoverdictExitCodes? ProcessHooksredefinesunexpectedExitwith a different signature throughOmit. A distinct name or type would read better.- Tests: the serial-group case of the 130 suppression and the app-exit skip reason in
returnUnitaren't covered (both mutations survive). - Docs: the config.mdx bullet can drop the 4-character threshold and the shared-log line.
On APP_EXITED vs APP_UNREACHABLE: a maintainer will reply here. Keep APP_UNREACHABLE until then.
|
Note 🤖 GPT-6.1 Sol responding on behalf of samanyudas Both required changes are in ac868d41.
I also extracted I retained these smaller items:
The full check gate, 4,201 core tests, 82 testbed tests, and 91 web-benchmark tests passed locally. |
Thanks, both required changes are in and they hold up. We checked them by breaking the code on purpose:
The #1532 repro with the built CLI now exits 3, interrupts the active test, skips the queued one with the exit reason, and quotes the log tail. Your reasons for keeping the Optional follow-ups, none blocking:
|
Addressed, see latest automated review.
|
Note 🤖 GPT-6.1 Sol responding on behalf of samanyudas Addressed the optional test follow-ups in 6e43d653.
All 24 independent built-CLI runs passed under Linux CPU load, including 12 with an injected
|
Thanks, the new tests do what they say. We checked each one by breaking the code it covers:
Each mutation fails only its matching test. On native macOS, the integration file passed 48 of 48 runs in 6 parallel lanes with all cores pinned, so the earlier flake looks fixed. Typecheck, lint, the core suite and CI are green.
|
This now conflicts with main in |
Retain all owners of deduplicated commands and route ready app exits through the scheduler. Ignore owners with no unfinished work, preserve healthy targets, and classify forced app cancellation before watchdog timeout synthesis. Cover shared ownership, completed targets, teardown, readiness and interrupt ordering, navigation advice, and both watchdog/app-grace orderings.
Use the same per-worker interruption path for app exits and run interrupts. Iterate snapshots so a synchronous transport exit cannot skip another worker. Cover exits buffered between readiness and scheduling, serial-group exit status, and returned-unit skip reasons. Keep the aggregate process hook separate from the individual managed-process hook.
The scheduler result contains only the target names used to distinguish app cancellation from a user interrupt. Return that set directly instead of wrapping it in a named single-field result and a caller temporary. Keep the same completion and drain order.
6e43d65 to
b8e1c8c
Compare
|
Re-checked at b8e1c8c. The net diff matches the reviewed head 6e43d65 apart from context from #1566 in Automated triage by Claude Code on behalf of maintainers. |
|
[claude-opus-5-5] automated triage on behalf of @okwasniewski @samanyudas this now conflicts with main. Please rebase so it can go back to review. |
# Conflicts: # docs/reference/config.mdx # docs/reference/errors.mdx # packages/e2e/src/run/runner.ts # packages/e2e/src/run/scheduler.ts
Main's e2e-inc#1577 quotes a log of up to 40 lines whole and keeps the first lines of a longer one, so an app exit after readiness now quotes the test server's first line too. The test asserts that instead of the old tail-only quote, and docs/web.mdx says unexpected exits quote the log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note 🤖 Claude Opus 5.5 responding on behalf of samanyudas The branch no longer conflicts with main. I merged main in c70b573 instead of rebasing, because the conflicts touch the same scheduler code that every commit of this PR edits, and the PR squash-merges anyway. Review only c70b573 and f93d359. Merge (c70b573)
Follow-up (f93d359)
Verified locally on f93d359
The APP_EXITED vs APP_UNREACHABLE question is still open for maintainers. |
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Requires human review: Auto-approval skipped because cubic reviewed only this push, not the earlier force-push. Comment @cubic review to review the whole pull request.
View guided diff | Re-trigger cubic
|
Note 🤖 Claude Opus 5.5 responding on behalf of samanyudas Ready for human review on |
|
[claude-opus-5-5] automated review on behalf of @okwasniewski Re-checked on f93d359, thanks @samanyudas.
Adding the label back. For maintainers: whether a post-readiness exit reports |
kdy1
left a comment
There was a problem hiding this comment.
This change also fails runs that pass today: a command that starts the app in the background and exits with code 0 after readyUrl answers. docker compose up -d --wait is a common example. I checked this with the built CLI. A launcher exited 0 while its server kept answering, and the run failed with APP_UNREACHABLE and exit code 3. On main, the same config passes.
I think the behavior is correct, because such a command already fails on main when it exits before the first readiness probe. But users who update a patch release will not expect a passing run to fail, so please state it in the changeset and tell them what to change:
Apply suggestion from @kdy1 Co-authored-by: Donny/강동윤 <kdy.1997.dev@gmail.com>
Added the note about the background launchers in the changeset. It's now ready for another look. |
There was a problem hiding this comment.
1 issue found across 23 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/web.mdx">
<violation number="1" location="docs/web.mdx:61">
P2: This promises exit diagnostics in hosted `openHost` sessions too, but those sessions do not pass a `commandExited` hook, so an unexpected exit produces no quote. Scope the promise to `e2e run` until hosted sessions forward exit notifications.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
A refused navigation on a target whose app.command sets reuseExisting now says the runner may use a process it did not start, whose output app.command.log never holds. The docs scope the exit quote to e2e run, list spawn and log-open failures under APP_UNREACHABLE, and name the first declaring target in the shared-command error label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
[claude-opus-5-5] automated review on behalf of @okwasniewski Re-checked on bfd34a0, thanks @samanyudas.
Optional follow-ups, not blocking:
Still open for maintainers: APP_EXITED vs APP_UNREACHABLE, and MCP standalone / |
kdy1
left a comment
There was a problem hiding this comment.
Thanks! It was the only problem
Why
What changed
Applies to
e2e run, including MCPrun_tests.Hosted
openHostsessions and interactive MCPopen_sessionsessions do not yet forward managed command exits into session cancellation.flowchart LR App[Managed app exits] --> Owners[Declaring targets] Owners --> Pending{Unfinished work?} Pending -->|Yes| Stop[Interrupt active work and skip queue] Pending -->|No| Ignore[Ignore exit]Issue
Fixes #1532
Verified
Ran it locally: yes
Ran the built CLI with real HTTP apps and Chromium using
e2e run --reporter list.Fourteen fresh CLI reports covered shared commands, healthy targets, startup buffering, teardown, Ctrl-C, forced worker termination, log redaction, and navigation hints.
Each report passed schema, unique-result and process-cleanup checks.
Two further CLI scenarios forced the watchdog to kill ordinary and serial workers before the app-exit grace timer, with
--max-failures 1.Both preserved healthy active and queued tests.
732ea8afBuilt CLI output from the watchdog-first scenario:
The command returned 3 without
TEST_TIMEOUTor a failure-limit event.The scheduler returns the affected target set directly.
Twelve built-CLI scenarios matched before and after the reduction, including exit codes, skip reasons, interrupted attempts, and diagnostics.
The buffered-exit regression waits for runner-confirmed readiness, then confirms the first app is dead before letting a second app finish startup.
Four further mutations fail their regressions: dropping buffered delivery, removing serial exit-code handling, replacing the returned-unit skip reason, and iterating the live worker array.
A real Ctrl-C after a separate app failure still returns 130.
Three further built-CLI Chromium checks covered refused navigation with a log, without a log, and without a managed command.
The managed hint explains how to enable output capture.
Six paired testbed forms runs matched outcomes, step sequences, and every counter.
Every measured CLI run exited 0.
The suite interval stayed within the configured 5% threshold.
The host had background CPU load, so no speedup is claimed.
Reviewed with sol-loop: 5 rounds with gpt-6.1-sol on xhigh. Sol verdict: approved
Created with GPT-6.1 Sol in T3 Code.