Skip to content

fix(imessage): handle rpc stdin write errors#75473

Closed
addu2612 wants to merge 1 commit intoopenclaw:mainfrom
addu2612:fix/imessage-rpc-stdin-write
Closed

fix(imessage): handle rpc stdin write errors#75473
addu2612 wants to merge 1 commit intoopenclaw:mainfrom
addu2612:fix/imessage-rpc-stdin-write

Conversation

@addu2612
Copy link
Copy Markdown
Contributor

@addu2612 addu2612 commented May 1, 2026

Summary

Fixes #75438.

This adds local stdin failure handling for the iMessage RPC client so broken pipe errors reject the affected request instead of escaping through the process-level uncaught exception path.

Changes:

  • attach an error listener to the imsg rpc stdin stream and fail pending requests when the pipe breaks
  • reject the pending request when stdin.write() reports an error through its callback
  • add focused regression coverage for both the async stdin error path and the write callback error path
  • add a changelog entry

Verification

  • pnpm exec vitest run extensions/imessage/src/client.stdin-write-error.test.ts extensions/imessage/src/status.test.ts extensions/imessage/src/monitor.watch-subscribe-retry.test.ts
  • pnpm exec vitest run extensions/codex/src/app-server/client.test.ts src/infra/unhandled-rejections.test.ts
  • pnpm exec oxfmt --check --threads=1 extensions/imessage/src/client.ts extensions/imessage/src/client.stdin-write-error.test.ts CHANGELOG.md
  • pnpm exec oxlint extensions/imessage/src/client.ts extensions/imessage/src/client.stdin-write-error.test.ts extensions/imessage/src/status.test.ts

@openclaw-barnacle openclaw-barnacle Bot added channel: imessage Channel integration: imessage size: S labels May 1, 2026
@addu2612 addu2612 force-pushed the fix/imessage-rpc-stdin-write branch from f1c46a0 to e4afcc7 Compare May 1, 2026 06:51
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented May 1, 2026

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Close as implemented on current main. The iMessage RPC client now has both sides of the requested stdin failure handling: a stream error listener for async EPIPE and a write callback that rejects the pending request, with changelog coverage for the linked crash report; the proof commit is on main and not in the latest shipped release yet.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the current main implementation and close this PR as redundant. If maintainers still want the exact extra iMessage regression test from the branch, that should be a small follow-up on top of main rather than merging an already-implemented duplicate patch.

Do we have a high-confidence way to reproduce the issue?

Yes. The reproduction path is a closed or errored imsg rpc stdin while IMessageRpcClient.request() is pending; current main can be verified by the stdin error listener and write callback that reject pending requests instead of leaving an uncaught EPIPE.

Is this the best way to solve the issue?

Yes for the underlying issue. Handling this in the iMessage-owned RPC client is the narrowest maintainable fix, and adjacent generic stdin write sites were handled separately in the merged #75602 work.

Security review:

Security review cleared: The PR diff only changes the iMessage client, adds a focused test, and updates the changelog; it does not alter dependencies, CI, packaging, secrets, or downloaded code paths.

What I checked:

  • current implementation: stdin error listener: Current main attaches an error listener to child.stdin and routes stream errors through failAll, preventing an unhandled stdin stream error from escaping to the gateway-level uncaught exception path. (extensions/imessage/src/client.ts:111, 0bb52118e6c8)
  • current implementation: write callback rejection: Current main writes RPC request payloads with a callback and rejects the matching pending request when the write callback receives an error. (extensions/imessage/src/client.ts:189, 0bb52118e6c8)
  • current changelog documents the iMessage fix: The active changelog records the iMessage IMessageRpcClient stdin write callback and error listener fix for IMessageRpcClient.request() does not handle async stdin write errors → uncaughtException → gateway crash #75438. (CHANGELOG.md:99, 0bb52118e6c8)
  • release provenance: git branch --contains shows the proof commit on main; git tag --contains returned no tags, so this is implemented on current main but not proven shipped in a release. The latest release in the provided context is v2026.4.29 at a448042, before the proof commit. (5c7362fe9d69)
  • dependency contract: Node v22 stream docs confirm writable write callbacks receive write errors before the stream error event, so the current callback-plus-listener shape matches the upstream stream contract for this failure mode.
  • related merged stdin work: The provided GitHub context shows fix: handle EPIPE errors on child process stdin writes #75602 was merged for adjacent child-process stdin EPIPE handling in MCP stdio and process exec paths, while current main separately contains the iMessage-specific implementation. (22e9656f54d1)

Likely related people:

  • steipete: The current-main proof commit and blame for the iMessage stdin listener/write-callback lines point to Peter Steinberger, and git shortlog --all -- extensions/imessage shows the largest share of iMessage-area history. (role: recent maintainer and proof-commit author; confidence: medium; commits: 5c7362fe9d69; files: extensions/imessage/src/client.ts, CHANGELOG.md)
  • vincentkoc: Recent iMessage monitor/type-check/refactor history includes multiple commits by Vincent Koc, and the area is adjacent to the RPC lifecycle that uses IMessageRpcClient. (role: recent iMessage maintainer; confidence: medium; commits: ea71a59127, 35a784c165, 503b43f43f; files: extensions/imessage/src/monitor/monitor-provider.ts, extensions/imessage/src/client.ts)
  • amknight: The related merged fix: handle EPIPE errors on child process stdin writes #75602 in the provided context handled the same child-process stdin EPIPE class in sibling MCP stdio and process exec paths. (role: adjacent stdin EPIPE fix owner; confidence: medium; commits: 22e9656f54d1; files: src/agents/mcp-stdio-transport.ts, src/process/exec.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 0bb52118e6c8; fix evidence: commit 5c7362fe9d69, main fix timestamp 2026-05-01T21:08:43Z.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: imessage Channel integration: imessage size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IMessageRpcClient.request() does not handle async stdin write errors → uncaughtException → gateway crash

1 participant