Skip to content

fix(rpc): catch :exit/:throw from erpc.call; handle {:exception, :terminating} (OPS-4536)#8

Open
palantir-valiot[bot] wants to merge 1 commit into
mainfrom
palantir/OPS-4536-handle-erpc-terminating
Open

fix(rpc): catch :exit/:throw from erpc.call; handle {:exception, :terminating} (OPS-4536)#8
palantir-valiot[bot] wants to merge 1 commit into
mainfrom
palantir/OPS-4536-handle-erpc-terminating

Conversation

@palantir-valiot

Copy link
Copy Markdown

Summary

Catch :exit (including the {:exception, :terminating} form that erpc.call surfaces when the remote MFA does exit(R)) and :throw in Relix.RPC.execute/1. Previously these bypassed the rescue and propagated as unhandled exits, crashing callers such as TokenHelper.authorize_token_via_rpc (valiot_app) at the first occurrence.

The change:

  • Wrap the :erpc.call in both rescue (for exceptions) and catch :exit, ... / catch :throw, ....
  • Log the failure with module, function, arity, and node (same style as the existing rescue path).
  • Surface a normalized {:error, {:rpc_exit, reason}} as resp_body so the RPC struct has status: :executed and RPC.response/1 returns {:error, ...} instead of crashing the process.
  • Added TDD tests that deliberately cause the exact exit/throw shapes and assert clean {:error, ...} results.

Files changed: lib/relix/rpc/relix_rpc.ex, test/relix_test.exs, mix.exs, mix.lock, CHANGELOG.md.

Why

Root cause of OPS-4536 (eliot-lamosa-gto-prod): unhandled {:exception, :terminating} from erpc.call at lib/relix/rpc/relix_rpc.ex:60 (stack: Relix.RPC.execute/1TokenHelper.authorize_token_via_rpc → Context plug → GraphQL).

Triage: NOTIFY+FIX, severity high, category code_bug. This is a missing error-handling path on a first-party RPC helper; frequency 0 does not downgrade it.

Test plan

  • mix test (was red for the new case before the edit; 7/7 green after: 1 doctest + 6 tests including two new ones for {:exception, :terminating} and throw)
  • mix format
  • Per baseline rules: ran mix hex.outdated, bumped allowed dev dep ex_doc 0.40.1 → 0.40.3 (and transitive makeup_erlang) in the same PR; updated mix.lock
  • Version bumped to 0.1.5; one-line CHANGELOG entry added
  • git diff inspected before commit (no debug prints, no scope creep, no empty diff)
  • Always used git push-safe (never plain git push)
  • TDD: failing test committed first, made green by the minimal targeted edit

Closes OPS-4536

@linear-code

linear-code Bot commented Jun 13, 2026

Copy link
Copy Markdown

OPS-4536

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants