#2744: FIX(imessage): preserve signal info in RPC close handler
channel: imessage
Cluster:
Cross-Platform Fixes
The original code intended to report signal information when the imsg RPC process was killed (evidenced by the `signal ?` ternary on line 95). However, the condition `code !== 0 && code !== null` prevented this from ever happening.
When a process is killed by a signal (e.g., SIGTERM):
- code is null
- signal is "SIGTERM"
The old condition evaluated as: (null !== 0) && (null !== null) = false This routed signal kills to the else branch, losing the signal info.
Changed to `code !== 0 || signal` so signal-killed processes now correctly report "imsg rpc exited (signal SIGTERM)" instead of the generic "imsg rpc closed" message.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the iMessage RPC client process close handler to correctly propagate termination details when the underlying `imsg rpc` child process exits due to a signal. Specifically, it changes the exit-condition check from `code !== 0 && code !== null` to `code !== 0 || signal`, allowing signal-terminated processes (where `code` is `null` and `signal` is set) to report `imsg rpc exited (signal …)` instead of falling back to the generic `imsg rpc closed` error.
This logic lives in `src/imessage/client.ts` inside `IMessageRpcClient.start()`, where the child process lifecycle is managed and pending JSON-RPC requests are failed when the child terminates.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change is narrowly scoped to the child-process close handler and corrects a clearly incorrect boolean condition that previously dropped signal termination information. It does not affect other control flow paths, data formats, or external interfaces.
- No files require special attention
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#4784: fix(imessage): handle non-JSON output from imsg CLI gracefully
by spiceoogway · 2026-01-30
78.7%
#12984: fix(signal): fall back to JSON-RPC for health check on signal-cli 0...
by omair445 · 2026-02-10
72.8%
#23724: fix(security): sanitize RPC error messages in signal and imessage c...
by kevinWangSheng · 2026-02-22
72.7%
#7660: fix(signal): route group reactions to group sessions
by ClawdadBot · 2026-02-03
71.7%
#10709: fix(signal): guard JSON.parse against malformed RPC responses
by Yida-Dev · 2026-02-06
71.5%
#7353: fix: prevent silent message drops after config.patch restart
by 18-RAJAT · 2026-02-02
70.9%
#18664: fix(imessage): honor groupConfig regardless of allowlistEnabled
by brandonwise · 2026-02-16
70.8%
#2799: fix(imessage): prevent self-chat and outbound echo loops (#2585)
by Tfh-Yqf · 2026-01-27
69.6%
#19398: feat(signal): support native signal-cli JSON-RPC WebSocket
by jxstanford · 2026-02-17
69.1%
#8271: feat(signal): Add full quoted message context support
by ProofOfReach · 2026-02-03
69.0%