fix(rpc): report open_failed when a worker dies before its open commits

CO
11m ago
+154-1

Fixes #4037

Problem

When an RPC session worker dies before its open commits (for example a worker that cannot load its modules), it reports the failure and exits. The exit closes the path claims and write grants the open is still awaiting, so claims.claim / reserve throw session_closing and openSession hands that to the client. The worker's real error only reaches stderr. #1953 had fixed this for the post-commit check only.

Fix

In the catch at the end of WorkerSessionRegistry.openSession: when the worker reported a failure and the step failed with session_closing, rethrow open_failed with the worker's error (same mapping as the #1953 post-commit check). Other errors are unchanged.

Tests

  • test/suite/regressions/issue-4037-worker-load-failure-open-error.test.ts: a worker that reports "Cannot find module ..." and exits during prepare (before the path is claimed). Fails without the fix (expected 'session_closing' to be 'open_failed'), passes with it.
  • After npm run build: rpc-worker-reservations, issue-1953-…, issue-4037-… and 1612-rpc-session-grant-release pass (4 files, 8 tests). tsc, oxfmt, oxlint, lint ratchet and the changelog gate pass.

Overlap

senpi#3814 moves openSession into worker-session-open.ts. Whichever lands second carries this 3-line guard into the final catch (cause) of the open there.


Summary by cubic

Fixes #4037. When an RPC session worker dies before its open commits (for example one that cannot load its modules), it closes what the open is still awaiting: the path claims and write grants report a typed session_closing, and the request channel rejects the pending prepare with a plain session_closing or session_worker_exited. Previously openSession surfaced that to the client and the worker's real error only reached stderr. It now recognizes both forms via closedByWorkerDeath and rethrows open_failed with the worker's failure, matching the post-commit check added in #1953.