Skip to content

fix: prevent statusline example script from hanging on blocked stdin - #699

Open
akunzai wants to merge 1 commit into
google-antigravity:mainfrom
akunzai:fix/statusline-stdin-timeout
Open

fix: prevent statusline example script from hanging on blocked stdin#699
akunzai wants to merge 1 commit into
google-antigravity:mainfrom
akunzai:fix/statusline-stdin-timeout

Conversation

@akunzai

@akunzai akunzai commented Jul 27, 2026

Copy link
Copy Markdown

Summary

  • examples/statusline/statusline.sh reads stdin unbounded (jq reads directly from the live pipe). During auth/OAuth refresh or resume-conversation warm-up, the CLI's statusline runner can hold stdin open without writing or closing it, so the script hangs until the runner's ~5-10s hard kill (statusline: command failed: signal: killed). Enough consecutive kills auto-disables the custom statusline.
  • Added a short timed stdin read up front (run_with_timeout 0.25 cat, with a portable fallback when GNU timeout isn't available) and close stdin immediately after (exec 0</dev/null) so nothing later in the script can block on it.
  • Default JSON_INPUT to "{}" when nothing arrived in time, so the script still renders a degraded status line instead of crashing on an empty read.
  • Verified with a deterministic repro (named pipe whose writer never writes/closes, mirroring the runner's documented behavior): before the fix the script hangs until an external timeout 5 kills it (exit 124, ~5s); after the fix it returns in ~0.27s with a valid degraded render (exit 0). Normal JSON input on stdin still renders exactly as before.

Closes #698

Test plan

  • bash -n examples/statusline/statusline.sh
  • Normal JSON input on stdin renders identical output to before the change
  • Blocked-stdin repro (named pipe, writer never writes/closes) no longer hangs — returns in ~0.27s instead of being killed at the 5s test-harness timeout
  • Empty/no stdin input renders a degraded status line (exit 0) instead of crashing

The example script read stdin unbounded (jq reading directly from the
live pipe). During auth/OAuth refresh or resume-conversation warm-up,
the CLI's statusline runner can hold stdin open without writing or
closing it, so the script hangs until the runner's ~5-10s hard kill
(signal: killed), and enough consecutive kills auto-disables the
custom statusline.

Read stdin with a short timeout up front, close it immediately after
(exec 0</dev/null) so nothing later can block on it, and default to
"{}" when no input arrived in time so the rest of the script still
renders a degraded status line instead of crashing on empty read.

Closes google-antigravity#698
@google-cla

google-cla Bot commented Jul 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@weby-homelab

weby-homelab commented Aug 13, 2026

Copy link
Copy Markdown

Hi @google-antigravity team and contributors! 👋

Great catch and fix in this PR regarding stdin handling in statusline.sh!

We have independently analyzed this issue and confirmed that when the CLI runner holds stdin open during OAuth refresh, authentication flow, or conversation warm-up without sending data or EOF, unbounded reads (cat or direct jq input) block indefinitely until the runner's ~5–10s hard SIGKILL limit. As noted, consecutive kills cause the CLI to auto-disable custom statusline plugins.

We have integrated this exact fix and enhanced resilience across both Bash (statusline.sh) and PowerShell (statusline.ps1) in our dedicated plugin repository:
👉 weby-homelab/antigravity-cli-statusline (v0.2.3 release)

image

Key Improvements in v0.2.3:

  • Bash (statusline.sh): Implemented a 0.25s run_with_timeout stdin guard with exec 0</dev/null and fallback default INPUT_JSON="{}" to ensure graceful degraded rendering (~350ms response) instead of process termination.
  • PowerShell (statusline.ps1): Added an asynchronous [System.Threading.Tasks.Task]::Run read with a 250ms timeout when IsInputRedirected is true.
  • Empirical Validation: Verified with a non-closing named pipe reproducer; execution returns clean degraded telemetry in <360ms with exit code 0.

If anyone is looking for a production-ready, feature-rich statusline plugin with dynamic line-packing, system resource telemetry, and built-in stdin hang protection, feel free to try antigravity-cli-statusline!

Kudos to the author for initiating this fix! 🚀

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.

[Bug]: Custom statusline script can hang indefinitely on blocked stdin, gets SIGKILL'd, and auto-disables after repeated failures

2 participants