Repository navigation
fix(run): quote a long app log's first lines in APP_UNREACHABLE - #1577
Conversation
There was a problem hiding this comment.
4 issues found across 6 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="packages/e2e/src/run/managed-process.ts">
<violation number="1" location="packages/e2e/src/run/managed-process.ts:376">
P2: The non-overlapping path returns every line in both 4 KiB windows, so a dense log can quote hundreds of lines instead of the promised first and last 20. Slice `head` to its first 20 lines and `tail` to its last 20 before adding the marker.</violation>
</file>
<file name="docs/web.mdx">
<violation number="1" location="docs/web.mdx:62">
P2: A 25-line log is quoted in full, without an omission marker; the marker is not added merely because output exceeds 20 lines. Clarify that overlapping windows include all lines and reserve the marker for non-overlapping windows.</violation>
</file>
<file name="docs/reference/config.mdx">
<violation number="1" location="docs/reference/config.mdx:524">
P2: A command that fails to spawn never reaches the log formatter, so this unconditional startup-failure claim is too broad. Limit it to failures after the command starts and when `log` is set.</violation>
<violation number="2" location="docs/reference/config.mdx:527">
P2: A 25-line log still fits the overlapping windows, so the runner includes every line without a marker. Say the marker appears only when the output windows do not overlap.</violation>
</file>
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.
Thanks @DeryFerd, the direction is right. On the built CLI the #1527 case is fixed: the FATAL line now shows first, where main showed only ticks 21-40. The 3 new tests fail on main and pass here. A few things need fixing before this is ready.
Must fix
-
The line cap is lost when the windows don't meet (
managed-process.ts, thehead/tailbranch ofoutputSince). Neither window gets cut to 20 lines, so a 4 KiB window of short lines quotes hundreds of them. 3000 lines liket123gave 1524 lines fromoutputSinceand 1131 in the realAPP_UNREACHABLEmessage, while the docs and changeset promise first and last 20. Usehead.slice(0, OUTPUT_TAIL_LINES)andtail.slice(-OUTPUT_TAIL_LINES). -
The fragment is dropped after empty lines are filtered (
readLines). If the clipped end fragment is only whitespace or control codes (the head window cut inside a stack trace's indent,Error: x\n),filterremoves the fragment andpop()then drops the complete line before it. Reproduced:Error: complete linedisappeared. That spot, the end of the head, is exactly where an early fatal error lands. Drop the fragment on the raw split, then filter. The start side has the same order on main, and this fixes both. -
Tests. The 300-line test only checks
toContainandlength < 9000, which is how bug 1 got past it. Please add exact-equality cases for:- non-overlapping windows with short lines (count and order)
- a log that already had content before the command started (
offset > 0) - a clipped fragment at the head's end (covers bug 2)
9 of 13 mutations survive the unit file, among them: swapping head and tail order, removing the clipped-end
pop,clippedEnd = falseon the head,clippedStart = falseon the tail, and always printing the marker even with an empty head. -
Docs.
errors.mdx:106adds em dashes. The repo uses plain hyphens.config.mdx:524andweb.mdx:62say "up to 20 lines". The actual behavior is: up to 40 lines quoted whole, otherwise 20 + marker + 20.web.mdx:62changes "any process appended" to "the process appended". The old wording was right, because the log can be shared (see the comment aboveoutputSince: an earlier service may still be writing to it).
Nits
readLinestakes 6 positional args, two of them booleans.endonly feeds the peek clamp, which is dead:clippedEndis only true whenheadEnd < end. Dropend, or pass{ clipStart, clipEnd }.OUTPUT_TAIL_LINES/OUTPUT_TAIL_BYTESnow size the head too. Rename them toOUTPUT_WINDOW_*.- The
unreachable()JSDoc still says "the log's tail". - If the head window is a single huge line,
headcomes back empty and the tail is returned with no marker, so the output is cut without saying so. Consider always emitting the marker when the windows don't meet. - The changeset could be one plain user-facing sentence. "Message cap" is an internal detail.
Heads up: #1541 (fixes #1532) touches the same APP_UNREACHABLE paragraphs in config.mdx and errors.mdx and conflicts textually. Once it lands, unreachable() also quotes the log for exits after the app was ready, so [startup output omitted] would read better as [output omitted].
CI: the test (26) failure is packages/web/tests/integration/screenshot-navigation.test.ts, an unrelated web flake. spec gate only fails because of it.
Checked and fine: empty log, offset past end, a shrunk file, CRLF, a first line at offset kept, a multibyte character split only inside dropped fragments, redaction per line on both windows, and adjacent windows with no duplicated line.
This is an automated review.
db26eba to
8ac60f1
Compare
|
Addressed in 8ac60f1 (one commit, rebased on main). 1. Line cap. 2. Fragment order. 3. Tests. The 300-line
The 25-line case still asserts the whole log when nothing is dropped. 4. Docs. Nits. The marker stays Verified on this head. CI. |
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
View guided diff | Re-trigger cubic
8ac60f1 to
c40bbd1
Compare
okwasniewski
left a comment
There was a problem hiding this comment.
Automated review (agent-run triage).
Re-review of c40bbd1. Almost there: every prior ask is fixed and the code is right on every edge case I tried (3000 short lines -> 41 quoted, CRLF, no trailing newline, 8191-8194 bytes, offset after a previous run's unfinished line, multibyte splits, empty and 40/41-line logs). CI green.
Must fix
- The overlap branch (
managed-process.ts:372-374) has no test with more than 40 lines. That is a log over 40 lines but at most 8 KiB, the most common shape. Removing the cap (return true), dropping the marker there, or changing* 2to* 3all pass. Add an exact-equality test, e.g. 100 lines ofline N. - The docs promise more than the code does (
config.mdx:524-528,web.mdx:62,errors.mdx:106). "Up to 40 of them whole" and "first and last 20 lines" ignore the 4 KiB per-window byte cap. 10 lines of 1 KiB each quote 4 + marker + 4, and 60 lines of 290 bytes quote about 14 + 14. Say "up to" and mention the byte bound, or drop the exact counts.
Nits
- errors.mdx:106: with the inserted clause, "
command.envvalues redacted, or says there was none" no longer reads as one sentence. - managed-process.ts:366-367:
Math.min(end, ...)/Math.max(offset, ...)are dead.end - offset <= 2 * OUTPUT_WINDOW_BYTESsays the same thing more simply. - The "keeps the first line the command wrote" test can use
toBe('fatal: EADDRINUSE')instead oftoContain. - The changeset has no trailing newline.
- Untested: exact line-boundary cuts (always-shift and always-pop mutations survive) and the marker after a huge first line.
Mutations: 33 run, 16 killed, 13 real survivors, 4 equivalent. Most survivors go away with must-fix 1 plus a boundary-cut test.
Still conflicts with #1541 in config.mdx/errors.mdx. Whichever merges second rebases.
Superseded by re-review of c40bbd1 (automated review).
c40bbd1 to
559af44
Compare
|
@okwasniewski addressed in 559af44 (one commit, rebased on main). Must fix 1, the overlap branch had no test past 40 lines. Added
Must fix 2, docs promised more than the code does. All three pages now state the byte bound: a log of up to 40 lines inside 8 KiB is quoted whole, a longer one shows up to 20 lines from each end, taken from the 4 KiB at each end, with the marker between. That covers your 10 × 1 KiB case (4 + marker + 4) and the 60 × 290-byte case (about 14 + 14) instead of implying 20 and 20. Nits.
Boundary cuts. Added
Verified on 559af44. The #1541 conflict in |
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Requires human review: Auto-approval blocked by 7 unresolved issues from previous reviews.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
Automated review (agent-run triage).
Re-review of 559af44. Close: the code is right, must-fix 1 is done (all 3 overlap mutations are killed), and every nit is taken. I accept your always-shift/always-pop equivalence argument. A 300k-input fuzz (CRLF split at the edge, ANSI, cut multibyte, tabs) found no difference. Two small things are left.
Must fix
docs/reference/errors.mdx:106still has no byte bound, although config.mdx and web.mdx now do. "Up to 40 lines whole" is wrong for a short log of long lines: 10 lines of 1 KiB quote 3 + marker + 3. The inserted sentence also leaves "Without one" reading as if it means "a longer log". Simplest fix: drop the counts on this page, e.g. "The quote keeps the first and last lines of a long log, with[startup output omitted]between them."
Should fix
- Nothing tests the byte threshold of the overlap branch (
end - offset <= OUTPUT_WINDOW_BYTES * 2):*1and*3both pass the suite. Two tests that pass on this head close it:- 25 lines of 250 bytes (~6.3 KB) are quoted whole. This kills
*1. - 10 lines of 1024 chars quote exactly lines 0-2, the marker, then 7-9. This kills
*3, and it is also the case the docs describe.
- 25 lines of 250 bytes (~6.3 KB) are quoted whole. This kills
Nit
- config.mdx/web.mdx "taken from the 4 KiB at each end" isn't strictly true for a log under 8 KiB with more than 40 lines, where the head can reach past 4 KiB. Fine to ignore.
Ran
- managed-process tests: 34/34 pass.
- tsc, oxlint, check-changeset-bumps and check-error-codes: all clean.
- The log-path-cannot-be-opened test passes on macOS on both main and this branch, which matches your Windows-only note.
- It merges cleanly into main, but still conflicts with #1541 in config.mdx and errors.mdx. Whichever lands second rebases.
A process that fails early and then keeps logging - a file watcher, say - buried the startup error under its own tail: the message quoted only the last 20 lines appended since the command started. It now quotes the first and last 20 lines with `[startup output omitted]` between them when the log is longer, both windows still byte-bounded and passed through the same redactor, so the error that explains the failure survives. Fixes e2e-inc#1527
559af44 to
789a047
Compare
|
@okwasniewski both in 789a047 (one commit). Must fix, Should fix, the overlap byte threshold. Both tests are in, and they pass on this head:
Ran the mutations you named against the file:
The second test is also the shape the docs describe, so it doubles as documentation coverage. Nit, the 4 KiB clause. Fixed in both pages rather than ignored: "A log of up to 40 lines inside 8 KiB is quoted whole. Otherwise the quote keeps up to 20 lines from each end, with Verified on 789a047. No source change this round, only the two tests and the three docs, so the built-CLI measurement from the previous head still describes this one: 3,000 short lines after a log a previous run left mid-line quote 41 lines, The #1541 conflict in |
There was a problem hiding this comment.
0 issues found across 4 files (changes from recent commits).
Requires human review: Auto-approval blocked by 7 unresolved issues from previous reviews.
View guided diff | Re-trigger cubic
|
Automated re-review (agent-run triage) at Both CR 3 asks done:
managed-process tests 36/36, tsc and oxlint clean, CI green. 21/30 mutations killed; 6 survivors are equivalent (incl. always-pop, your argument holds). Labeling Ready for Human Review. Optional
For maintainers: still conflicts with #1541 (Ready) in |
Asks addressed, see re-review comment.
kdy1
left a comment
There was a problem hiding this comment.
I verified the before & after of the log messages
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>
A process that fails early and then keeps logging (a file watcher, say) buried the startup error under its own tail: the message quoted only the last 20 lines appended since the command started. Now a log of up to 40 lines inside 8 KiB is quoted whole. A longer one quotes its first and last 20 lines with `[startup output omitted]` between them, both windows still byte-bounded and passed through the same redactor. Port of e2e-inc/e2e#1577 (9289ff4). Fixes #1505. Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
…1541) * test(core): reproduce app commands exiting after readiness * fix(core): fail runs when app commands exit after readiness * test(core): tighten app exit outcomes and diagnostic docs * fix(core): scope app command exits to dependent targets 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. * fix(core): clarify app readiness and output guidance * fix(core): share app command interruption and cover buffered exits 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. * refactor(core): return app-exit target set directly 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. * test(core): cover app-exit guards and process liveness * test(core): expect app exits to quote short logs whole 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> * docs(changeset): note that background launchers now fail Apply suggestion from @kdy1 Co-authored-by: Donny/강동윤 <kdy.1997.dev@gmail.com> * fix(core): keep reused app hints from promising command output 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> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Donny/강동윤 <kdy.1997.dev@gmail.com>
What and why
app.commanddies during startup, theAPP_UNREACHABLEmessage is often the only diagnostic a run leaves. With acommand.log, it quotes what the process appended since it started,command.envandinheritEnvvalues redacted.outputSince(offset)read a single window at the end of the file, so nothing before it could be recovered downstream. It now reads the other end too.What changed
packages/e2e/src/run/managed-process.ts:outputSincereads two windows ofOUTPUT_WINDOW_BYTES(4 KiB), one from the command's own log offset and one ending at the end of the file.[startup output omitted], the last 20.this.redactpass as before.packages/e2e/src/run/managed-process.ts: the inline read became a module-levelreadLines(fd, from, to, { start, end })helper that both windows share.packages/e2e/tests/unit/managed-process.test.ts:keeps the last 20 lines onlybecame a whole-log test, since a 25-line log has nothing omitted now. New exact-equality tests cover the line cap on both branches, both byte thresholds of the overlap check, cuts inside a line and exactly between lines, the whitespace fragment, anoffset > 0log with and without a final newline, and the marker after a huge first line.docs/web.mdx,docs/reference/config.mdx,docs/reference/errors.mdx: the quote is described as whole for a short log, otherwise the first and last lines with the marker between them. The config page names the byte bound..changeset/app-unreachable-first-lines.md:e2epatch.flowchart TD A[app.command fails at startup] --> B[read the log since the command started] B --> C{do the head and tail windows meet?} C -- yes --> L{more than 40 lines?} L -- no --> D[quote every line] L -- yes --> E C -- no --> E[first 20 lines] E --> F[startup output omitted] F --> G[last 20 lines] D --> H[redact command.env and inheritEnv values] G --> H H --> I[APP_UNREACHABLE message]Issue
Fixes #1527
Verified
Ran it locally: yes
Surface: the
APP_UNREACHABLEmessage the built CLI prints whenapp.commandexits before the app is ready, on a scratch project whose command writes one fatal line, one line namingDATABASE_URL, then 40 watcher lines, and exits 1. The main side below is thedistbuilt before this change, the branch side is the same command after rebuildingpackages/e2e.DATABASE_URLis missing, so no value could leak<secret:DATABASE_URL>expected [ ' line 41', ... ] to equal [ ' line 1', ... ]), then passing after the change. The whole file on the latest head: 34 passed, 1 failed, 1 skipped.fails with APP_UNREACHABLE when the log path cannot be opened, and it fails on this machine onmaintoo, with the change stashed: opening a directory as an append log resolves here instead of throwing, so noInfrastructureErroris raised. Windows-only, unrelated to this change.tsc --noEmitonpackages/e2e: exit 0.oxlinton both changed files: 0 warnings, 0 errors.check-changeset-bumps.tsandcheck-error-codes.ts: exit 0.pnpm checkchain and the browser-backed integration suites, which need a full build of every package (about twelve minutes here) and Chromium. CI ran them on the latest head and thespec,benchmark,mobile, anddocsgates passed. The change touches no engine code, no wire format, and no exported type.Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures.e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.