Repository navigation
Protect attach startup grace - #516
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes airc join --attach startup idempotent by preventing concurrent attach invocations from restarting (and killing) a scope’s background transport while it is still in the “starting; no heartbeat yet” window. It does this by treating a degraded transport-health result as “startup-in-progress” if the scope pidfile is sufficiently fresh (within AIRC_STARTUP_GRACE_SEC, default 45s), while still restarting truly stale cases.
Changes:
- Add
_join_transport_in_startup_graceto detect “startup-in-progress” based on pidfile mtime +transport_healthoutput. - Replace the prior boolean
--quiethealth probe with a captured-output health check, enabling attach-vs-restart decisions and better diagnostics.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+513
to
+517
| if [ "$_health_rc" != "0" ] && _join_transport_in_startup_grace "$_health_out" "$_early_pidfile"; then | ||
| local _early_pids; _early_pids=$(cat "$_early_pidfile" 2>/dev/null | tr '\n' ' ') | ||
| echo " airc join: AIRC process is still starting in this scope (AIRC PIDs: $_early_pids)." | ||
| printf '%s\n' "$_health_out" | sed 's/^/ /' || true | ||
| _join_show_status_and_inbox |
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
airc join --attachcalls from killing each other while a live transport is still startingstarting; no heartbeat yetand the pidfile is withinAIRC_STARTUP_GRACE_SEC(default 45s), treat the process as startup-in-progress and attach instead of restartingstale heartbeat,stale bearer pid, or outside the grace window)Observed after #514/#515 Mac destructive validation: multiple Claude attach tabs could race. One starts a valid background transport, another sees
DEGRADED ... starting; no heartbeat yetand restarts the scope, producingTerminated: 15loops and killing the Monitor foreground. This patch makes startup idempotent.Tests
Follow-up from #511/#514/#515 validation.