Skip to content

fix(stack): accept database helper readiness from its log - #7930

Open
avallete wants to merge 3 commits into
developfrom
avallete/flaky-docker-storage-attach-ready
Open

avallete wants to merge 3 commits into
developfrom
avallete/flaky-docker-storage-attach-ready

Conversation

@avallete

@avallete avallete commented Dec 3, 2026

Copy link
Copy Markdown
Member

TL;DR

Database helper startup no longer depends only on the start --attach stream to see the helper's ready line.

  • DockerDatabaseStorage.integration.test.ts › recovers after its shared helper is removed externally: the re-created helper printed supabase-helper-ready (it is in docker logs and the helper stays running), but the attach stream never delivered it, so startup timed out after 30s. Readiness now races the attach stream with logs --follow on the helper and takes the first source that reports ready; a failed or silent log follower never wins, and the readiness span records helper.ready_source. A new test covers an attach stream that drops the ready line.

ref

spotted in: https://github.com/supabase/cli/actions/runs/46883655541/job/143469003518


Generated by Claude Code

The `start --attach` stream can drop the helper's ready line while the
helper keeps running, so startup waited out the 30s readiness timeout.
Readiness now also follows the helper's log and takes whichever source
reports it first; the readiness span records which one did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MBEk1P9Wa6uFrNKhW7kMB8
@avallete
avallete requested a review from a team as a code owner December 3, 2026 07:45
@avallete
avallete requested a review from Coly010 December 3, 2026 07:45

avallete commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

/ai-review


Generated by Claude Code

@avallete avallete added the run-flaky-check Run the flaky-test check on this PR label Dec 3, 2026 — with Claude
@github-actions github-actions Bot removed the run-flaky-check Run the flaky-test check on this PR label Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

CLI benchmark (Lightweight Commands): no changes found

Commit c2556fe against develop at 7e95031 · 10 runs each · report only, never blocks merging

Command Workload Before After Change
supabase --version version 110 ms 111 ms no real change
supabase --help help 98 ms 102 ms no real change
supabase init init 107 ms 113 ms no real change (+6%, within normal variation)
supabase migration new bench migration-new 103 ms 104 ms no real change
supabase config convert config-convert 102 ms 105 ms no real change
supabase config validate config-validate 114 ms 114 ms no real change
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 122 ms 123 ms no real change
supabase projects list projects-list 114 ms 111 ms no real change
supabase functions list --project-ref replayfixtureprojref functions-list 116 ms 119 ms no real change

API calls: unchanged for all 9 commands.

Binary size: 135.1 MB, unchanged.

Details: timing ranges, API calls per command, slowest phases

Timing ranges

Command Workload Before range After range Change Verdict
supabase --version version 101-124 ms 100-122 ms +0 ms (+0%) within noise
supabase --help help 95-109 ms 95-124 ms +4 ms (+4%) within noise
supabase init init 97-146 ms 97-135 ms +6 ms (+6%) within noise
supabase migration new bench migration-new 99-112 ms 99-109 ms +1 ms (+1%) within noise
supabase config convert config-convert 100-111 ms 100-109 ms +2 ms (+2%) within noise
supabase config validate config-validate 110-122 ms 110-116 ms 0 ms (0%) within noise
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 120-126 ms 119-132 ms +0 ms (+0%) within noise
supabase projects list projects-list 108-166 ms 106-123 ms -2 ms (-2%) within noise
supabase functions list --project-ref replayfixtureprojref functions-list 112-123 ms 114-129 ms +3 ms (+2%) within noise

API calls per command

Command Workload Before After Endpoint changes
supabase --version version 0 0
supabase --help help 0 0
supabase init init 0 0
supabase migration new bench migration-new 0 0
supabase config convert config-convert 0 0
supabase config validate config-validate 0 0
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 2 2
supabase projects list projects-list 1 1
supabase functions list --project-ref replayfixtureprojref functions-list 2 2

Slowest phases

No command moved beyond noise, so there are no phase deltas.

Workflow run

Comment /bench to run the lightweight benchmark (this comment) again on the latest commit, or /bench full to also run the integration-heavy benchmark, which posts in its own comment.

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by a newer AI review

🤖 AI Review

CLI reference prose guidance: not applicable (no reference sources changed).

Both reviews identified a startup ordering bug that can leave the new log fallback idle until the 30-second timeout. A separate finding confirms that attach EOF or a stream error can cancel the fallback before it reports readiness. The new test covers a silent attach stream paired with an immediate log marker. Verification was static because the local Docker socket denied access. The diff contains no CLI reference prose changes.

Findings

Severity Location Category Sources Claim
🟠 MAJOR packages/stack/src/storage/DockerDatabaseStorage.ts:712 startup-race claude+codex If Docker handles the single log-follow request before the helper starts, the follower can exit empty. If the attach stream also misses the readiness marker, the storage operation fails after 30 seconds even though the helper became ready.
🟠 MAJOR packages/stack/src/storage/DockerDatabaseStorage.ts:729 correctness codex If attach stdout closes, errors, or produces a different first line while the helper is still running, it can cancel the log fallback before the readiness marker arrives and cause startup to fail.

Stats

Claude findings: 1 · Codex findings: 2 · Confirmed: 2 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

),
Effect.catch(() => Effect.never),
);
return yield* Effect.raceFirst(attachedLine, loggedReady).pipe(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 MAJOR · correctness · source: codex

If attach stdout closes, errors, or produces a different first line while the helper is still running, it can cancel the log fallback before the readiness marker arrives and cause startup to fail.

Evidence: DockerDatabaseStorage.ts:699–706 reads the first attach line and uses Effect.tap only to annotate a matching marker. At line 729, Effect.raceFirst accepts the first completion. Lines 732–745 check for the marker after the race and kill the attached child on failure. DockerDatabaseStorage.integration.test.ts:608–613 keeps the attach stream open indefinitely, so the test cannot exercise an early attach completion.

Suggested fix: Keep the log fallback active when attach stdout ends or errors without a marker. Preserve prompt failure when Docker confirms the helper exited, and add a test where attach reaches EOF before the log marker arrives.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping the current behavior. The helper is create --rm -i, so the attach owns its lifetime: when the attach ends or errors, Docker removes the helper, and failing fast with the attach's stderr is the intended outcome. If the log fallback kept waiting, a real exit would turn into a 30s timeout with worse diagnostics. The flake this PR targets is an attach that stays open but never delivers the line, and that is what the fallback covers.


Generated by Claude Code

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

CLI reference prose guidance: not applicable (no reference sources changed).

The Docker database helper can still miss readiness in two ways. Attach EOF or a read error can cancel the log follower before it sees the marker, and a log request that reaches Docker before startup can finish without following. The tests cover a successful log fallback and a silent follower, but do not force a failed or empty follower to finish before attach reports readiness. Verification was static because the Docker socket denied access.

Findings

Severity Location Category Sources Claim
🟠 MAJOR packages/stack/src/storage/DockerDatabaseStorage.ts:729 correctness codex Attach EOF or a read error can end the readiness check and cancel the log follower before it reports that the helper is ready.
🟡 MINOR packages/stack/src/storage/DockerDatabaseStorage.ts:715 startup-race claude+codex The one-shot log follower can finish before Docker starts the helper, leaving the existing 30-second timeout in place if attach also misses the readiness marker.
⚪ NIT packages/stack/src/storage/DockerDatabaseStorage.integration.test.ts:608 test-coverage claude The tests do not force a follower spawn failure, EOF, or non-marker result to occur before attach delivers the readiness marker.

Stats

Claude findings: 2 · Codex findings: 2 · Confirmed: 3 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: manual · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

),
Effect.catch(() => Effect.never),
);
return yield* Effect.raceFirst(attachedLine, loggedReady).pipe(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 MAJOR · correctness · source: codex

Attach EOF or a read error can end the readiness check and cancel the log follower before it reports that the helper is ready.

Evidence: DockerDatabaseStorage.ts:699-707 lets attach EOF complete with None and propagates read errors. At line 729, Effect.raceFirst accepts that completion and interrupts the follower. Lines 732-745 then enter failure cleanup. DockerDatabaseStorage.integration.test.ts:608-612 keeps attach pending with Stream.never, so it cannot exercise either early completion.

Suggested fix: Keep the log follower active after attach EOF or a read error while the helper can still become ready. Handle confirmed helper exit separately, preserve the deadline and diagnostics, and test a log marker that arrives after attach EOF.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping the current behavior. The helper is create --rm -i, so the attach owns its lifetime: when the attach ends or errors, Docker removes the helper, and failing fast with the attach's stderr is the intended outcome. If the log fallback kept waiting, a real exit would turn into a 30s timeout with worse diagnostics. The flake this PR targets is an attach that stays open but never delivers the line, and that is what the fallback covers.


Generated by Claude Code

Comment on lines +608 to +613
stdout:
args[0] === "start"
? Stream.never
: following
? Stream.succeed(new TextEncoder().encode("supabase-helper-ready\n"))
: Stream.empty,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ NIT · test-coverage · source: claude

The tests do not force a follower spawn failure, EOF, or non-marker result to occur before attach delivers the readiness marker.

Evidence: DockerDatabaseStorage.integration.test.ts:608-613 makes the follower emit the marker immediately, and lines 504-512 keep it pending in the timeout test. The existing fake engine at lines 143-164 can return empty stdout for logs, but attach emits its marker immediately and the mirror-image test at lines 789-797 does not control the order.

Suggested fix: Use a controlled mock that completes the follower with EOF or a spawn error before releasing the attach marker, then assert that the storage operation succeeds.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The opposite ordering (log follower fails or is empty, then attach delivers the marker) is what every other fake-engine test in this file now runs through: their fake fails inspect --format {{.Created}} / logs, the fallback stays silent, and readiness comes from attach. A dedicated test would duplicate that.


Generated by Claude Code

`logs --follow` on a container that has not started yet returns at once
without following, so the readiness fallback could stay silent. The
fallback now waits for the helper's start event, replayed with
`--since` its creation time, before following its log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MBEk1P9Wa6uFrNKhW7kMB8
@avallete avallete added the run-flaky-check Run the flaky-test check on this PR label Dec 3, 2026 — with Claude

avallete commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Re AI review:

  • startup-race (:712): confirmed. Against a local daemon, logs --follow on a created-but-not-started container exits at once with no output. Fixed in 76bf9db: the fallback now waits for the helper's start event (events --since <Created> replays it even if the start already happened) and only then follows the log. The regression test asserts that order.
  • attach EOF/error cancels the fallback (:729): kept as is. The helper is create --rm -i, so the attach owns its lifetime: once the attach ends or errors, the helper is being removed, and failing fast with the attach's stderr is the intended outcome. Waiting for the log after that would only turn a real exit into a 30s timeout. A different first line also means the helper is not the expected program, so it is still treated as a failure.

Generated by Claude Code

@github-actions github-actions Bot removed the run-flaky-check Run the flaky-test check on this PR label Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Flaky test check: ✅ no flaky tests

Commit 2c675c64bf68 · focused ×10 (5 executions each), 10489 tests · integration ×10, 7908 tests · unit ×10, 10401 tests · workflow run

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.

@Coly010 Coly010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved with a few comments, none of them blocking so feel free to push back on any of them

Podman prints `{{.Created}}` in Go's default time format, which its
`events --since` does not accept, so the log fallback only applied to
Docker. Both formats now normalize to Unix seconds, which both engines
accept. Also tightens the fallback comment and test assertions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MBEk1P9Wa6uFrNKhW7kMB8

This branch has not been deployed

No deployments
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.

3 participants