← Back to PRs

#2744: FIX(imessage): preserve signal info in RPC close handler

by sal-jim open 2026-01-27 12:19 View on GitHub →
channel: imessage
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