Repository navigation
Conversation
…ch drops it A one-off container attached through `start --attach --interactive` can exit with a failure while the attach session relays no stderr, so a psql error reached the caller as an empty stream. When the attached stderr ends empty and the process failed, read the container's logged stderr before it is removed and relay that instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MBEk1Pbmd87VhSdE6Rb9aF
|
/ai-review Generated by Claude Code |
CLI benchmark (Lightweight Commands): no changes foundCommit
API calls: unchanged for all 9 commands. Binary size: 135.2 MB, unchanged. Details: timing ranges, API calls per command, slowest phasesTiming ranges
API calls per command
Slowest phasesNo command moved beyond noise, so there are no phase deltas. Comment |
There was a problem hiding this comment.
Superseded by a newer AI review
🤖 AI Review
CLI reference prose guidance: not applicable (no reference sources changed).
Verified all three findings from both independent reviews: one minor log-recovery concern and two nits are confirmed. No duplicates were identified. The log streams drain concurrently, but the timeout can still discard recovered stderr while waiting for replay completion. CLI reference prose review was not applicable.
Findings
| Severity | Location | Category | Sources | Claim |
|---|---|---|---|---|
| 🟡 MINOR | packages/stack/src/runtime/Container.ts:608 |
error-handling |
claude | The fallback replays the container's entire stdout and stderr under a 10-second timeout. For a failed tool with large logged stdout, replay can exceed that budget and discard all recovered stderr, including stderr already collected. |
| ⚪ NIT | packages/stack/src/runtime/Container.ts:612 |
correctness |
claude | Recovered stderr is decoded as UTF-8 and re-encoded, so invalid UTF-8 bytes are replaced rather than preserved in the Uint8Array stream. |
| ⚪ NIT | packages/stack/src/runtime/Container.ts:627 |
observability |
codex | The recovered-byte counter measures UTF-16 code units rather than bytes, undercounting non-ASCII stderr. |
Stats
Claude findings: 2 · Codex findings: 1 · Confirmed: 3 · Refuted: 0 · Uncertain: 0
Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run
This review runs once per PR. A maintainer can request another with a /ai-review comment.
| const child = yield* spawner.spawn(command(["logs", name])); | ||
| const [, stderr, code] = yield* Effect.all( | ||
| [ | ||
| child.stdout.pipe(Stream.runDrain), | ||
| child.stderr.pipe(Stream.decodeText, Stream.mkString), | ||
| child.exitCode, | ||
| ], | ||
| { concurrency: "unbounded" }, | ||
| ); | ||
| yield* Effect.annotateCurrentSpan("process.exit_code", Number(code)); | ||
| return Number(code) === 0 ? stderr : ""; | ||
| }), | ||
| ).pipe( | ||
| Effect.timeout("10 seconds"), | ||
| Effect.tapError((cause) => | ||
| Effect.logDebug(`Could not read logs of container ${name}`, cause), | ||
| ), | ||
| Effect.orElseSucceed(() => ""), |
There was a problem hiding this comment.
🟡 MINOR · error-handling · source: claude
The fallback replays the container's entire stdout and stderr under a 10-second timeout. For a failed tool with large logged stdout, replay can exceed that budget and discard all recovered stderr, including stderr already collected.
Evidence: Container.ts:608 invokes logs without --tail or --since. Lines 609-615 concurrently drain stdout, collect stderr, and await exit. Lines 621-625 convert a timeout of that whole operation into an empty string.
Suggested fix: Bound the replay with a limit such as --tail 200, and preserve stderr already collected if the recovery operation times out.
There was a problem hiding this comment.
Fixed in f7a9da5: stderr chunks are collected into a Ref as they arrive, so a timeout keeps what was already read. I left out --tail, because it counts stdout and stderr lines together and could cut the stderr we need when there is a lot of stdout.
Generated by Claude Code
| const [, stderr, code] = yield* Effect.all( | ||
| [ | ||
| child.stdout.pipe(Stream.runDrain), | ||
| child.stderr.pipe(Stream.decodeText, Stream.mkString), |
There was a problem hiding this comment.
⚪ NIT · correctness · source: claude
Recovered stderr is decoded as UTF-8 and re-encoded, so invalid UTF-8 bytes are replaced rather than preserved in the Uint8Array stream.
Evidence: Container.ts:612 collects stderr through Stream.decodeText and Stream.mkString; line 646 emits new TextEncoder().encode(text). ContainerProcess.stderr is a Uint8Array stream at line 81, and the ordinary attached path forwards its byte chunks at lines 639-640.
Suggested fix: Collect and concatenate raw Uint8Array chunks, emit those bytes directly, and use their byteLength for the recovery annotation.
There was a problem hiding this comment.
Fixed in f7a9da5: the raw stderr bytes are now passed through as-is, with no text decoding.
Generated by Claude Code
| ), | ||
| Effect.orElseSucceed(() => ""), | ||
| ); | ||
| yield* Effect.annotateCurrentSpan("container.stderr_recovered_bytes", text.length); |
There was a problem hiding this comment.
⚪ NIT · observability · source: codex
The recovered-byte counter measures UTF-16 code units rather than bytes, undercounting non-ASCII stderr.
Evidence: Container.ts:627 records text.length as container.stderr_recovered_bytes, while line 646 emits UTF-8 bytes. For example, é has text.length 1 but encodes to 2 bytes.
Suggested fix: Record the emitted Uint8Array's byteLength, reusing the encoded buffer or collecting raw bytes.
There was a problem hiding this comment.
Fixed in f7a9da5: the annotation now records the byteLength of the bytes that are emitted.
Generated by Claude Code
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MBEk1Pbmd87VhSdE6Rb9aF
There was a problem hiding this comment.
🤖 AI Review
CLI reference prose guidance: not applicable (no reference sources changed).
Verified all four findings as distinct minor issues: engine diagnostics can contaminate recovered stderr, recovery buffers stderr without a size cap, stdout replay can exhaust the recovery timeout, and the byte-count attribute undercounts non-ASCII output. CLI reference prose checks were not applicable.
Findings
| Severity | Location | Category | Sources | Claim |
|---|---|---|---|---|
| 🟡 MINOR | packages/stack/src/runtime/Container.ts:618 |
error-handling |
claude | Successful engine CLI warnings can be presented as container stderr because loggedStderr returns the logs subprocess's entire stderr without distinguishing engine diagnostics from container output. |
| 🟡 MINOR | packages/stack/src/runtime/Container.ts:612 |
resource-usage |
claude | Recovery collects the complete logged stderr into an unbounded string before emitting it, so large failed-tool logs can cause excessive memory use even when the consumer otherwise retains only a bounded tail. |
| 🟡 MINOR | packages/stack/src/runtime/Container.ts:611 |
performance |
claude | Recovery replays and discards the container's complete stdout history, which can exhaust the 10-second timeout and discard recovered stderr for stdout-heavy failed commands. |
| 🟡 MINOR | packages/stack/src/runtime/Container.ts:627 |
observability |
codex | The recovered stderr byte count is incorrect for non-ASCII diagnostics. |
Stats
Claude findings: 3 · Codex findings: 1 · Confirmed: 4 · Refuted: 0 · Uncertain: 0
Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: manual · Workflow run
This review runs once per PR. A maintainer can request another with a /ai-review comment.
| { concurrency: "unbounded" }, | ||
| ); | ||
| yield* Effect.annotateCurrentSpan("process.exit_code", Number(code)); | ||
| return Number(code) === 0 ? stderr : ""; |
There was a problem hiding this comment.
🟡 MINOR · error-handling · source: claude
Successful engine CLI warnings can be presented as container stderr because loggedStderr returns the logs subprocess's entire stderr without distinguishing engine diagnostics from container output.
Evidence: Container.ts:608-618 invokes logs and returns its unfiltered stderr on exit code 0; lines 645-646 emit it as container stderr. host/CommandRunner.ts:290 forwards this stream directly to input.stderr, and services/Database.ts:699 uses its trimmed contents as the error message.
Suggested fix: Suppress engine-generated warnings for the recovery invocation using supported engine options while preserving container stderr; avoid filtering arbitrary container output by warning-shaped prefixes.
There was a problem hiding this comment.
Not changed. Neither docker logs nor podman logs has a supported flag that silences engine-side warnings separately from container stderr, and filtering by prefix would be guesswork, as you note. This path only runs when the attach session relayed no stderr and the tool failed, so an engine warning in the message beats an empty one. A maintainer can decide whether that tradeoff is acceptable.
Generated by Claude Code
| const [, stderr, code] = yield* Effect.all( | ||
| [ | ||
| child.stdout.pipe(Stream.runDrain), | ||
| child.stderr.pipe(Stream.decodeText, Stream.mkString), |
There was a problem hiding this comment.
🟡 MINOR · resource-usage · source: claude
Recovery collects the complete logged stderr into an unbounded string before emitting it, so large failed-tool logs can cause excessive memory use even when the consumer otherwise retains only a bounded tail.
Evidence: Container.ts:612 uses Stream.mkString without a size limit, and line 646 allocates an encoded buffer for the complete result. The ordinary run helper bounds retained text at lines 559-569, while Database.ts:685-690 bounds its downstream stderr collection only after recovery has buffered everything.
Suggested fix: Retain a bounded stderr tail during recovery, or stream recovered chunks without collecting the complete log.
There was a problem hiding this comment.
Fixed in 64c5ab6: recovery now keeps only the last 64 KiB of stderr chunks, which matches the run helper's bound.
Generated by Claude Code
| const child = yield* spawner.spawn(command(["logs", name])); | ||
| const [, stderr, code] = yield* Effect.all( | ||
| [ | ||
| child.stdout.pipe(Stream.runDrain), |
There was a problem hiding this comment.
🟡 MINOR · performance · source: claude
Recovery replays and discards the container's complete stdout history, which can exhaust the 10-second timeout and discard recovered stderr for stdout-heavy failed commands.
Evidence: Container.ts:608 invokes logs without a replay limit. Lines 609-615 wait for stdout drainage, stderr collection, and process exit together. Lines 621-625 replace the entire result with an empty string on timeout, including any stderr already collected.
Suggested fix: Bound engine-side replay, for example with a suitable logs --tail limit, or use a supported mechanism that retrieves only container stderr.
There was a problem hiding this comment.
Since f7a9da5, a timeout keeps the stderr collected so far instead of dropping it. I left out --tail: it counts stdout and stderr lines together, so with a lot of stdout it could cut exactly the stderr this path exists to recover. Recovery only runs for a one-off tool that failed with no attached stderr at all.
Generated by Claude Code
| ), | ||
| Effect.orElseSucceed(() => ""), | ||
| ); | ||
| yield* Effect.annotateCurrentSpan("container.stderr_recovered_bytes", text.length); |
There was a problem hiding this comment.
🟡 MINOR · observability · source: codex
The recovered stderr byte count is incorrect for non-ASCII diagnostics.
Evidence: Container.ts:627 records container.stderr_recovered_bytes using text.length, which counts UTF-16 code units. Line 646 emits UTF-8 bytes using TextEncoder: é records 1 while emitting 2 bytes, and an emoji records 2 while emitting 4 bytes.
Suggested fix: Record the UTF-8 encoded buffer's byteLength, preferably reusing that buffer for emission.
There was a problem hiding this comment.
Fixed in f7a9da5: the annotation now records the emitted buffer's byteLength.
Generated by Claude Code
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MBEk1Pbmd87VhSdE6Rb9aF
Flaky test check:
|
| Suite | Test | File | Failed | Where | First failure |
|---|---|---|---|---|---|
| focused | managed migration squash > docker squashes through an owned shadow stack | apps/cli/src/commands/migration/squash/squash.native.integration.test.ts |
1/50 | 8.4 | Error: managed squash failed: ed3f17bf-81ae-4bc0-b908-420d159727cb failed: Engine command 'start' did not finish within 30s; container state: status=running started=2026-11-18T08:01:31.06501425Z pid=7… |
| focused | stops its containers and exits when its whole state root is confirmed gone | packages/stack/src/StackHost.container-shutdown.integration.test.ts |
1/50 | 4.4 | StackError: b07f22ed-7037-46c3-8979-372f5112d9d3 failed: Engine command 'start' did not finish within 30s; container state: status=running started=2026-11-18T08:02:06.445218204Z pid=745582 error=: Eng… |
Each execution is a separate Vitest process; Where lists failing runs, as run.iteration for suites executed more than once per run. The full data is in the flaky-check-report artifact.
|
The Generated by Claude Code |
TL;DR
A one-off tool container can fail while its attach session relays no stderr; the runtime now reports the container's logged stderr in that case.
Commands.integration.test.ts › podman runs SQL from stdin, streams a dump, and returns client failure: psql exited 3 on the early-exit stdin case but the caller saw an empty stderr. Output comes only fromstart --attach --interactive, so an attach session that ends before relaying stderr loses the psql error for every caller, not only the test. When the attached stderr ends empty and the process failed, the runtime now readslogsfor the container (before it is removed) and relays its stderr, under aContainer.loggedStderrspan that records the recovered byte count. A new container integration test drops the attach stderr and checks the failure output still arrives.ref
spotted in: https://github.com/supabase/cli/actions/runs/44064870746/job/133975841072
Generated by Claude Code