Skip to content

fix(cli): stop hanging on a closed output pipe (CLI-2507) - #7469

Merged
7ttp merged 4 commits into
developfrom
7ttp/cli-2507-supabase-status-spins-at-160-cpu-forever-when-stdout-and
Nov 3, 2026
Merged

7ttp merged 4 commits into
developfrom
7ttp/cli-2507-supabase-status-spins-at-160-cpu-forever-when-stdout-and

Conversation

@7ttp

@7ttp 7ttp commented Nov 3, 2026

Copy link
Copy Markdown
Member

TL;DR

stops the cli spinning forever when the reader of its output exits early

whats improved/fixed?

piping text output into a reader that exits early, like supabase projects list | true, left the cli spinning at full cpu and never exiting, and --debug did the same

progress lines and --debug logs write to the pipe directly, so bun marks the stream failed without the output writer noticing, and the next write waits for a drain that never comes

how?

every stdio write, from the output writer and the debug trace spans alike, now fails right away on an already failed stream, so the existing closed pipe handling ends the run with exit 0

each write also runs without yielding, so the late error event from a direct write cannot slip past that check

ref:

@7ttp 7ttp self-assigned this Nov 3, 2026
@7ttp
7ttp requested a review from a team as a code owner November 3, 2026 14:41
@7ttp
7ttp requested a review from kanadgupta November 3, 2026 14:41
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

CLI benchmark (Lightweight Commands): no changes found

Commit 8dd0788 against develop at 00c8a5b · 10 runs each · report only, never blocks merging

Command Workload Before After Change
supabase --version version 239 ms 238 ms no real change
supabase --help help 207 ms 212 ms no real change
supabase init init 230 ms 228 ms no real change
supabase migration new bench migration-new 275 ms 246 ms no real change (-11%, within normal variation)
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 270 ms 280 ms no real change
supabase projects list projects-list 231 ms 235 ms no real change
supabase functions list --project-ref replayfixtureprojref functions-list 241 ms 238 ms no real change

API calls: unchanged for all 7 commands.

Binary size: 134.0 MB, unchanged.

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

Timing ranges

Command Workload Before range After range Change Verdict
supabase --version version 198-309 ms 188-289 ms -2 ms (-1%) within noise
supabase --help help 197-320 ms 180-284 ms +5 ms (+2%) within noise
supabase init init 194-254 ms 203-374 ms -2 ms (-1%) within noise
supabase migration new bench migration-new 216-319 ms 212-456 ms -30 ms (-11%) within noise
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 236-310 ms 237-375 ms +10 ms (+4%) within noise
supabase projects list projects-list 205-321 ms 216-409 ms +3 ms (+1%) within noise
supabase functions list --project-ref replayfixtureprojref functions-list 216-306 ms 211-300 ms -3 ms (-1%) 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 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.

🤖 AI Review

Both independent reviews were available. Confirmed a scheduler-test coverage gap and a narrowly scoped robustness nit concerning injected Stdio services. The pinned Bun 1.4.4 returns null for healthy process streams, so the hypothetical missing-property crash was not observed. Full tests could not run because dependencies are absent.

Findings

Severity Location Category Sources Claim
🟡 MINOR apps/cli/src/shared/output/output.layer.unit.test.ts:881 test-quality codex The scheduler regression test can pass if a yield between the preflight check and sink subscription reintroduces the missed-error hang.
⚪ NIT apps/cli/src/shared/output/output.layer.ts:97 robustness claude The preflight check gates injected Stdio sinks on the real process streams: a healthy substitute sink is skipped whenever the corresponding process stream is errored. It also treats undefined as an error, so a replacement process stream lacking the errored property would turn ordinary output into a PlatformError defect.

Stats

Claude findings: 1 · Codex findings: 1 · Confirmed: 2 · 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.

@kanadgupta kanadgupta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no notes from me ✅ per the claude analysis below, i'd ask the user to install the next beta build and confirm that they can no longer reliably reproduce the issue on macOS 27

claude analysis

LGTM

No blocking findings. One thing is unverified: the macOS 27 trigger.

Why the fix works

  • A direct write to a closed pipe returns false, but Bun sets errored one microtask later.
  • A sink attached after that misses the error event and waits for drain forever.
  • writeStdio checks errored first and never yields before the sink listens, so the late event can't be missed.
  • A sample of a hung pre-fix binary shows the same kevent64 spin as in #6846.

What I ran

Real binary on macOS 26.7 (Bun 1.4.4), reader closed, 3 runs each:

Case Pre-fix This PR
--debug, stderr closed hangs 3/3 (~100% CPU) exits 0, 3/3
5 other closed-pipe cases exits 0 exits 0
  • New E2E fails on the pre-fix binary (60 s timeout) and passes on this PR.
  • 126 unit tests in the two touched suites pass.
  • oxlint, oxfmt --check and tsc --noEmit are clean on the changed files.
  • CI is green.
  • No other code writes to stdout or stderr through Stdio, so nothing is missed.

Not verified

  • I couldn't reproduce the macOS 27 cases (status, db query --linked, projects list). They need Docker or a linked project.
  • I don't know why macOS 27 sends progress writes into the closed pipe first. A timing race fits the "2 of 3 runs hang" report, but that is a guess.
  • Suggest asking the #6846 reporters to try a preview build on macOS 27.

Non-blocking note

  • If errored isn't EPIPE (for example EIO after a terminal closes), the run now fails with an error instead of hanging. That is fine as is.

@7ttp
7ttp added this pull request to the merge queue Nov 3, 2026
Merged via the queue into develop with commit c94ecf3 Nov 3, 2026
49 checks passed
@7ttp
7ttp deleted the 7ttp/cli-2507-supabase-status-spins-at-160-cpu-forever-when-stdout-and branch November 3, 2026 21:48
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.

supabase status spins at ~160% CPU forever when stdout and stderr share a pipe whose reader closes early

2 participants