Skip to content

fix(hooks): preserve unread messages when stdout is closed - #1685

Closed
fujibee wants to merge 1 commit into
mainfrom
fix/hook-closed-stdout
Closed

fujibee wants to merge 1 commit into
mainfrom
fix/hook-closed-stdout

Conversation

@fujibee

@fujibee fujibee commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

On Ubuntu 26.04, a Stop-hook invocation with stdout closed could consume messages without delivering its payload. The installed uutils cat 0.10.0 reopens a missing fd 1 on /dev/null and exits successfully, so the hook interpreted a discarded payload as a successful delivery.

Emit the Stop payload with the shell builtin printf, as the other emit paths already do. This preserves the JSON bytes and makes a closed stdout fail the write, leaving the messages unread. The existing regression and its expectations remain unchanged.

Validation: reproduced the failure on Ubuntu 26.04/Bash 5.3.9 and traced cat observing EBADF on fd 1, opening /dev/null as fd 1, and exiting 0. The successful-delivery and closed-stdout regressions pass with the fix. Ubuntu 24.04/Bash 5.2 did not reproduce the original failure. The full tests/test_delivery.bats suite completed with exit 0 on Ubuntu 26.04 as a non-root user with LANG=C.UTF-8 (221 cases, 3 platform skips). The same 221-case file also completed with exit 0 on macOS. bash -n scripts/check-inbox.sh and git diff --check pass.

Emit Stop payloads with the shell builtin printf. On Ubuntu 26.04,
uutils cat reopens a missing stdout on /dev/null and returns success,
causing the hook to consume messages that were never delivered.

Keep the existing write-status barrier and consume-after-success rule.
The closed-stdout regression fails before this change and passes after
it on Ubuntu 26.04; its expectations are unchanged.
@fujibee

fujibee commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Landed on main in 1.6.0 (#1529).

@fujibee fujibee closed this Oct 23, 2026
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.

1 participant