Repository navigation
fix(run): exit 3 when a passed test's cleanup failed - #1233
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
|
Hi, this PR is ready for review. Its CI runs are parked at the first-time-contributor approval gate (action_required), so the checks cannot start until a maintainer approves the run. Could you approve it when you have a moment? Thanks! |
okwasniewski
left a comment
There was a problem hiding this comment.
Thanks @Varshith-Kali. Exit 3 here is the right call: docs/reference/cli.mdx (exit-code table) already lists "artifact, or cleanup infrastructure failure" under 3, so the run was breaking its own documented contract. The fold is small and covers serial groups too. Two things block it, though.
Must fix
-
The PR breaks an existing integration test, and fork CI hasn't run yet, so nothing caught it.
packages/e2e/tests/integration/engine-contract.test.ts:491("a failing endAttempt marks cleanup failed ... but keeps the test passed") assertsoutcome.exitCodeis0at line 507. On this branch it gets3(expected 3 to be +0). With the runner.ts change reverted and dist rebuilt, it passes. Flip that assertion to3and rename the test so it states the new contract. Note that integration tests run againstdist, so builde2eand@e2e-dev/webbefore you run them. -
The terminal still says everything passed, and then the process exits 3. I ran a fake-engine project whose
endAttemptthrows, with the list reporter on. The output was✓ taps a node,Test Files 1 passed,Tests 1 passed, then exit 3 with nothing explaining why.report.jsonhasrun.status: "error". A CI user sees a red job under a green summary. Please make the list reporter show the cleanup failure (code + message) under the passed test or in the summary (packages/e2e/src/report/list.ts), and add an integration test that checks the output. -
verdictExitCodesis exported only so the new unit test can import it (packages/e2e/src/run/runner.ts:1264). AGENTS.md: "An export whose only consumer is a test is dead production API - make it module-private or move it." The integration test from point 1 already pins this behavior through the real runner. Please keep the function private and droptests/unit/runner-exit-codes.test.ts, or replace it with a fake-engine integration test where a required video's stop fails (createFakeEngine({ video: true, ... })withvideo: 'on'), which is the exact #1231 scenario.
Nits
runner.ts:1284: thecleanupErrors.length === 0fallback can't fire. Every place that setscleanup = 'failed'on the run path also pushes aphase: 'cleanup'secondary error (execute.tscloseSessionandstopVideo). Dropping the branch leaves one loop: pushexitCodeForCategory(error.category)for each cleanup-phase secondary error of an attempt whosecleanup === 'failed'. The "no recorded secondary error" unit test builds a record the runner never produces.runner.ts:1257-1263: the new JSDoc paragraph argues the design. Shorten it to one line, e.g. "An attempt whose cleanup failed adds its cleanup errors' codes, even when the test passed."docs/reference/errors.mdx:44-48: per the docs style, keep it to what users need, e.g. "A passed test whose cleanup failed (a required video that was not finalized, a session that did not close) exits with that cleanup error's code, usually 3." Drop the "its loss is not a success" rationale.tests/unit/runner-exit-codes.test.ts:3uses an em dash. Use a plain hyphen.- The changeset is fine as a patch. Two sentences are enough: what changed and what it means for CI.
For the maintainer
- With this change a
flakyresult (documented as exit 0) exits 3 if an earlier, failed attempt lost its required video. The loop covers every attempt, not just the final one. That matches "a requested artifact was lost", but please confirm it's intended.
This was an automated review.
The CHANGES_REQUESTED review on e2e-inc#1233 asked for eight changes, all implemented here. The endAttempt integration test now asserts exit 3 and is renamed to state the new contract. The list reporter shows each cleanup failure (code and message) under its passed or flaky test and adds a Cleanup row to the final summary, so a run that exits 3 no longer prints a green summary. verdictExitCodes is module-private again and its unit test is gone, replaced by a fake-engine integration test in which a required video's stop fails, the exact e2e-inc#1231 scenario; the fake engine gained an onStopVideo hook to make that failure expressible. The unreachable no-secondary-error fallback is dropped, leaving one loop over the cleanup-phase secondary errors of every attempt whose cleanup failed. The JSDoc paragraph is one line, the errors.mdx paragraph keeps to what users need, and the changeset is two sentences as a patch. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
The exit-code fold only looked at verdict statuses and run errors, so a run whose tests all passed but whose required video could not be finalized exited 0 with the report's attempt-level cleanup failure as the only trace. A cleanup failure is an artifact/infrastructure failure the run asked for: verdictExitCodes now folds in the cleanup-phase secondary error's category (infrastructure, exit 3, when the record carries none), for ordinary and serial-group attempts alike. Forced cleanups stay on the interrupt's code. Closes e2e-inc#1231 Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
…irst verdictExitCodes used find() for the cleanup-phase secondary error, so when an attempt recorded more than one (a required video that would not finalize plus a session that would not close), a later higher-precedence category such as internal was dropped before combineExitCodes ran. Fold in each cleanup error's category instead, keeping the infrastructure fallback when the record carries none. Adds a regression test for the multi-error case. Also corrects the exit-code reference: the run exits with the cleanup error's category code, defaulting to 3, rather than unconditionally 3. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
The CHANGES_REQUESTED review on e2e-inc#1233 asked for eight changes, all implemented here. The endAttempt integration test now asserts exit 3 and is renamed to state the new contract. The list reporter shows each cleanup failure (code and message) under its passed or flaky test and adds a Cleanup row to the final summary, so a run that exits 3 no longer prints a green summary. verdictExitCodes is module-private again and its unit test is gone, replaced by a fake-engine integration test in which a required video's stop fails, the exact e2e-inc#1231 scenario; the fake engine gained an onStopVideo hook to make that failure expressible. The unreachable no-secondary-error fallback is dropped, leaving one loop over the cleanup-phase secondary errors of every attempt whose cleanup failed. The JSDoc paragraph is one line, the errors.mdx paragraph keeps to what users need, and the changeset is two sentences as a patch. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
fc85df1 to
19e55fe
Compare
|
Thanks for the review. All eight points are addressed in 19e55fe. One note on the push: main had moved since the last head, so I rebased onto current main. The rebase resolved a single conflict hunk in list.ts, keeping both upstream's new Left out field and this change's new Cleanup field; nothing else in the change was altered by it.
For the maintainer, confirming explicitly: yes, the loop covering every attempt, not just the final one, is intended. verdictExitCodes iterates every attempt of every verdict, so a flaky result whose earlier failed attempt lost its required video exits 3, matching "a requested artifact was lost". The earlier attempt's cleanup failure is a cleanup-phase secondary error on that attempt, and the fold picks it up exactly like a final attempt's. Verified locally against fresh dist builds of e2e and @e2e-dev/web: typecheck clean, oxlint clean, report-list unit 80 passed, list-reporter integration 2 passed, engine-contract integration 43 passed. |
The cleanup fold covers every attempt, so a skipped test whose endAttempt throws is a run level infrastructure failure, not a passing run. The test keeps asserting the result stays skipped. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
|
Thanks, this was the same miss as point 1, in a second file. The missed test is Decision: update the test, not the fold. The fold in Change in d8307a6: renamed the test to "exits 3 when a skipped test cleanup fails, keeping the test skipped", flipped the assertion from 0 to 3, and added an assertion that the result status stays Verified locally against the built dist (which already carries the fold, so no rebuild was needed): |
|
Thanks @Varshith-Kali. All 8 points from the last review are in at d8307a6. CI is fully green. What I checked:
Nits
This was an automated review. |
All asks addressed at d8307a6 (automated review).
Address review nits on e2e-inc#1233: move cleanupErrorsOf into run/records.ts next to failureBeforeSkip and use it in both the list reporter and verdictExitCodes; drop the stale JSDoc paragraph in runner.ts; fix the passed-test wording in errors.mdx and the changeset since a skipped test whose cleanup failed also exits 3; trim the cleanupLines JSDoc to one line. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
|
All 4 nits are in at 06ca585:
Verified: skip-after-failure integration suite 7/7 green, e2e unit suite 200 files / 3034 tests green, oxlint clean on the touched files. The package typecheck shows the same 5 pre-existing |
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
|
Replying to the cubic P3 on the changeset (review 5661122207): fixed as 6ce8945. The changeset now says a CI job that goes red names the cleanup failure instead of reporting a green summary. You were right that not every cleanup failure on this path is a missing artifact (session-close and other engine cleanup errors take the same path), so the note no longer implies that. |
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
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=".changeset/cleanup-failure-exit-code.md">
<violation number="1" location=".changeset/cleanup-failure-exit-code.md:5">
P3: The changeset overstates list-reporter output for skipped tests: their cleanup failure appears in the summary but not under the test row. Say this is shown under passed or flaky tests, or update the reporter to render cleanup lines for skipped tests.</violation>
</file>
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
| "e2e": patch | ||
| --- | ||
|
|
||
| A run now exits with the cleanup error's code, usually 3, when a test's cleanup failed. The list reporter shows the cleanup failure under the test and in the summary, so a CI job that goes red names the cleanup failure instead of reporting a green summary. |
There was a problem hiding this comment.
P3: The changeset overstates list-reporter output for skipped tests: their cleanup failure appears in the summary but not under the test row. Say this is shown under passed or flaky tests, or update the reporter to render cleanup lines for skipped tests.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. 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. At .changeset/cleanup-failure-exit-code.md, line 5:
<comment>The changeset overstates list-reporter output for skipped tests: their cleanup failure appears in the summary but not under the test row. Say this is shown under passed or flaky tests, or update the reporter to render cleanup lines for skipped tests.</comment>
<file context>
@@ -2,4 +2,4 @@
---
-A run now exits with the cleanup error's code, usually 3, when a test's cleanup failed. The list reporter shows the cleanup failure under the test and in the summary, so a CI job that goes red names the missing artifact instead of reporting a green summary.
+A run now exits with the cleanup error's code, usually 3, when a test's cleanup failed. The list reporter shows the cleanup failure under the test and in the summary, so a CI job that goes red names the cleanup failure instead of reporting a green summary.
</file context>
| A run now exits with the cleanup error's code, usually 3, when a test's cleanup failed. The list reporter shows the cleanup failure under the test and in the summary, so a CI job that goes red names the cleanup failure instead of reporting a green summary. | |
| A run now exits with the cleanup error's code, usually 3, when a test's cleanup failed. The list reporter shows the cleanup failure under passed or flaky tests and in the summary, so a CI job that goes red names the cleanup failure instead of reporting a green summary. |
…y tests Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
|
Fixed, thanks. The finding was real: the changeset claimed the cleanup failure shows "under the test and in the summary", but the list reporter only renders cleanup lines under passed and flaky rows (testLine in packages/e2e/src/report/list.ts), while skipped rows render no cleanup lines. The summary line does cover every status, since testFinished records cleanup failures regardless of status. Fixed as 3b19749: the changeset now says the reporter shows the cleanup failure "in the summary and under the test for passed and flaky tests". No code change, the wording now matches the reporter exactly. |
|
Thanks @Varshith-Kali. I re-checked at 3b19749 and all 4 nits are done:
CI is fully green. Nothing left from my side. This was an automated review. |
|
Thanks for re-checking, and for confirming CI is fully green with nothing left from your side. The PR is ready on my side whenever you want to take it forward. |
#1231: a run whose tests all pass but whose required video cannot be finalized exits 0, with the loss visible only as an attempt-level
cleanup: "failed"and a secondary error. The exit-code fold never looked at cleanup state.verdictExitCodes(packages/e2e/src/run/runner.ts) now folds an attempt's failed cleanup into the exit code, for ordinary and serial-group attempts alike: the cleanup-phase secondary error's category, defaulting toinfrastructure(exit 3) when the record carries none.cleanup: "forced") is untouched: the interrupt already sets 130.docs/reference/errors.mdx) note the new rule under exit codes; changeset added.This covers both producers of
cleanup: "failed":stopVideofor a required recording (packages/e2e/src/run/execute.ts) and the session-close path, plus the standalone attempt's close. Best-effort recordings still fail quietly by design.Verified
Ran it locally: yes, at the unit level (a real video-finalization failure needs a browser; the regression test drives the exact record shape from the issue:
status: "passed",cleanup: "failed", aCLEANUP_TIMEOUTcleanup-phase secondary error).packages/e2e/tests/unit/runner-exit-codes.test.ts(8 tests): all fail on main, all pass here.tsc --noEmit: no new errors (only the pre-existing@e2e-dev/webresolution errors this env has on main);oxlint: clean.03(infrastructure), run statuserrorCloses #1231