Skip to content

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

Description

@dzbot92

Environment

  • Supabase CLI 2.116.0 (npm supabase, @supabase/cli-darwin-arm64); also observed on 2.118.0
  • macOS 27.0 (26A428), Apple Silicon (arm64)
  • Local stack running (supabase start)

Steps to reproduce

  1. npx supabase status 2>&1 | head -3

Expected

head prints three lines and exits; the CLI receives EPIPE/SIGPIPE on its next write and exits.

Actual

head exits, but the CLI process never does. It stays at 157-161% CPU until killed. sample shows the main thread looping in kevent64. Because the shell waits on every member of a pipeline, the command never completes. One background invocation ran for 14 hours before it was noticed.

Measurements (each run killed by a watchdog after 15-25 s)

Command Result
npx supabase status 2>&1 | head -3 hangs, 159.8% CPU after 24 s
npx supabase status 2>&1 | grep -q Stopped hangs, 157.5% CPU
node_modules/@supabase/cli-darwin-arm64/bin/supabase status 2>&1 | head -1 hangs, 161.2% CPU
npx supabase status 2>/dev/null | head -3 exits 0
npx supabase status 2>&1 >/dev/null | head -1 exits 0
npx supabase status 2>&1 | cat >/dev/null exits 0
X=$(npx supabase status -o json 2>/dev/null) exits 0

The hang requires both stdout and stderr in the same pipe, with a reader that closes before the CLI has finished writing. Piping only one stream, or draining everything, exits normally. Setting SUPABASE_NO_UPDATE_NOTIFIER=1 does not change the result.

Suggested fix

Exit (or stop writing) when a write to stdout or stderr fails with EPIPE, rather than retrying in the event loop.

Workaround

Capture the whole output first (X=$(supabase status -o json 2>/dev/null)) or redirect to a file, then read that.

Activity

  1. assigned and unassigned on Sep 27, 2026
  2. 7ttp commented on Sep 27, 2026

    @7ttp
    Member

    hey @dzbot92 thanks for this! 💚

    Couldn’t reproduce this locally on macOS 26.6.2, so the macOS version difference might be relevant
    could you share a gist of the full sample output from the hanging process?

  3. yannf86 commented on Oct 6, 2026

    @yannf86

    Reproduced on macOS 27.0 (26A428), Apple Silicon, Homebrew CLI 2.118.0 and 2.119.0. Given that it didn't reproduce on 26.6.2, the macOS version does look relevant.

    Our trigger was supabase db query --linked "..." 2>&1 | jq -c .. --linked prints Initialising login role... on stderr, jq stops with parse error: Invalid numeric literal at line 1, column 13, and the CLI keeps spinning at ~155% CPU. One run went unnoticed for 8 hours (12.5 h of CPU time).

    Measurements, each run killed by a watchdog after 20-25 s:

    Command 2.118.0 2.119.0
    db query --linked "select 1" 2>&1 | jq -c . hangs, 151.8% CPU hangs, 156.4% CPU
    db query --linked "select 1" 2>/dev/null | true hangs, 153.8% / 154.7% / 159.3% CPU (3 of 3 runs)
    db query --linked "select 1" 2>/dev/null | jq -c . exits 0 exits 0
    db query --linked "select 1" 2>/dev/null | cat >/dev/null exits 0
    db query --linked "<3000 rows>" 2>/dev/null | head -c 100 exits 0
    projects list with 2>&1 | true, 2>&1 >/dev/null | true, 2>/dev/null | true intermittent: 2 of the 3 hung in each of two runs; none hung in a third run, which added -o yaml/toml/json to tell the processes apart

    One correction to the original report: stderr doesn't have to share the pipe. With db query --linked, stdout alone hangs when the reader has already exited before the CLI's first write (| true). With projects list the same variants hang only some of the time, so it looks timing-dependent.

    While the process was spinning, lsof showed no TCP socket left open (the query had finished): fds 1 and 2 were on the dead pipe. sample shows the main thread looping through kevent64, __ulock_wake, os_unfair_lock_lock and clock_gettime. The worker threads are named Bun Pool 0/1 and HTTP Client.

    Full sample output of that 8-hour process (2.118.0), as requested: https://gist.github.com/yannf86/534758bafa5353fd3530e346271bac3b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions