Repository navigation
fix(connect): SIGPIPE-trap + heartbeat so silent-deafness launches fail loud - #32
Merged
Merged
Conversation
…il loud The bug a real user surfaced today: A peer ran `airc connect <invite>` via Claude Code's one-shot Bash tool (not via the /connect skill, which wraps in Monitor). The pairing succeeded, the python formatter + ssh tail spawned, messages.jsonl on the host filled correctly — but stdout had no reader because the bash that exec'd `airc connect` had already exited and closed the pipe. Result: airc was paired and "looked alive" in `airc peers`, but every inbound message went to a closed stdout and silently disappeared. The peer never saw any reply. Hours of debugging from both sides before anyone noticed the launch pattern was the cause. This is exactly the silent-failure-mode airc has no business shipping. A protocol whose whole purpose is "stream inbound messages to the agent" must NOT silently succeed when the stream has no reader. Fix: 1. Install a SIGPIPE trap in cmd_connect that prints a clear error to stderr (which usually survives even when stdout is dead) explaining the cause AND the right launch patterns, then exits non-zero. 2. Spawn a 60s-period heartbeat to stdout. If a reader is consuming stdout (Monitor / interactive TTY), the heartbeats are harmless filler. If stdout is closed (one-shot bash, nohup, '&' background, detached shell), the next heartbeat write triggers SIGPIPE → trap fires → loud death instead of silent deafness. 3. AIRC_BACKGROUND_OK=1 env var skips the heartbeat for the rare legitimate background launch (systemd unit + dedicated tail consumer, test harness with its own monitoring). Worst-case latency from "stdout closed" to "airc dies loudly" is 60s which is the price of catching the failure mode at all. Tunable later if anyone needs faster (heartbeat interval as env var). Triggered by: 2026-04-23 incident where continuum-6cae paired into continuum-a25c via /airc:connect <invite> launched as a Bash one-shot. Symptom: continuum-a25c sent 3 messages, none reached continuum-6cae's notification stream. Continuum-6cae's diagnosis (over the mesh) matched ours. Joel: "take every bug you encounter, especially for NEW users on like a NEW machine or OS as an OPPORTUNITY so do NOT hack it. You fix it. Look at it as a freaking gift."
19 of 32 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
airc connect <invite>is launched in a way that closes stdoutwithout anyone reading it (one-shot Bash exec,
nohup, background&,detached shell), the pairing succeeds, the python formatter and ssh
tail spawn correctly, and the host's
messages.jsonlfills asexpected — but every inbound peer message goes to a closed stdout and
silently disappears. The pairing looks alive in
airc peers, but theagent never sees a single notification.
This is the worst possible failure mode for a relay protocol: looks
healthy from the outside, totally deaf in practice.
Fix
cmd_connect. When any writeto stdout fails (closed pipe), the trap prints a loud, specific
error to stderr (which usually survives the closed-stdout case)
pointing at the right launch patterns, then exits with code 3.
subshell. With a live reader (Monitor, interactive TTY) the
heartbeats are harmless filler. With no reader, the next heartbeat
triggers SIGPIPE → trap fires → loud death within 60s.
AIRC_BACKGROUND_OK=1env var skips the heartbeat for legitimatebackground launches (systemd unit + dedicated
tail -fconsumer,test harnesses).
Worst-case latency from "stdout closed" to "airc dies loudly" is 60s —
the price of catching the failure mode at all. Heartbeat interval
could become an env knob in a follow-up if anyone needs faster
detection.
Why this matters
This bug surfaced today (2026-04-23) when a peer paired into a host
via Claude Code's Bash tool instead of via the
/connectskill (whichwraps in
Monitor(persistent=true)). The peer'sairc peersshowedthe host. The host's
airc peersshowed the peer. The host sent threemessages. None reached the peer. Both sides debugged for hours before
the launch pattern came up.
The relevant principle: a protocol whose entire purpose is "stream
inbound messages to the agent" must NOT silently succeed when the
stream has no reader. It is allowed to fail at startup, allowed to
fail loudly later, but is not allowed to look fine while being
functionally deaf.
Test plan
no reader) — confirmed inbound messages were silently dropped on
main.clear error pointing at correct launch patterns.
Monitor(persistent=true, command="airc connect <invite>")→heartbeats appear as benign Monitor events, no false-fail.
airc connect <invite>typed at shell)→ heartbeats visible inline, no false-fail.
AIRC_BACKGROUND_OK=1 nohup airc connect ... &→ heartbeatsuppressed, runs normally for legitimate background use.