fix: failed requests reach the page with an error code and the node's data (closes #533) #565

Merged
clawbot merged 1 commits from issue-533-rpc-error-codes into next 2026-10-18 22:12:11 +02:00
Collaborator

Implements #533 as planned on the issue.

A request the node refuses now reaches the page with the node's own JSON-RPC code and data. That covers a proxied read such as a reverting eth_call, an eth_sendTransaction whose gas estimate reverts, and a failed broadcast. Every other refusal the background sends also carries a code: 4100 when there is no address, and -32603 for a failure inside the wallet (an address switch, a refused signature, a node that cannot be reached).

requestError() in src/background/index.js builds each of these answers. On the transaction path the page keeps the wallet's own sentence, and only the code and data come from the node. src/content/inpage.js already passed both through and is unchanged.

The existing approval tests in tests/backgroundApproval.test.js now expect the codes. Its nonce-collision test throws the node's error under info.error, the place ethers puts it. The new test, tests/rpcErrorCodes.test.js, sends requests through the real background and real ethers to a fake node.

Judgement call: the two refusals in prepareApprovalTx() that blame the site's request (two different gas limits, a transaction type this wallet does not sign) answer -32602. The plan gave non-node preparation failures -32603, but its general rule gives -32602 to a request refused as malformed.

Deviation: nodeError(), which finds the node's error inside an ethers error, lives in src/shared/approvalVerify.js. failureTexts() already did the same lookup there inline, and both approvalTx.js and the background need it.

Unverified: not run in a browser.

Model: opus-5-5

Implements https://git.eeqj.de/sneak/AutistMask/issues/533 as planned on the issue. A request the node refuses now reaches the page with the node's own JSON-RPC `code` and `data`. That covers a proxied read such as a reverting `eth_call`, an `eth_sendTransaction` whose gas estimate reverts, and a failed broadcast. Every other refusal the background sends also carries a code: `4100` when there is no address, and `-32603` for a failure inside the wallet (an address switch, a refused signature, a node that cannot be reached). `requestError()` in `src/background/index.js` builds each of these answers. On the transaction path the page keeps the wallet's own sentence, and only the code and data come from the node. `src/content/inpage.js` already passed both through and is unchanged. The existing approval tests in `tests/backgroundApproval.test.js` now expect the codes. Its nonce-collision test throws the node's error under `info.error`, the place ethers puts it. The new test, `tests/rpcErrorCodes.test.js`, sends requests through the real background and real ethers to a fake node. Judgement call: the two refusals in `prepareApprovalTx()` that blame the site's request (two different gas limits, a transaction type this wallet does not sign) answer `-32602`. The plan gave non-node preparation failures `-32603`, but its general rule gives `-32602` to a request refused as malformed. Deviation: `nodeError()`, which finds the node's error inside an ethers error, lives in `src/shared/approvalVerify.js`. `failureTexts()` already did the same lookup there inline, and both `approvalTx.js` and the background need it. Unverified: not run in a browser. Model: opus-5-5
clawbot added 1 commit 2026-10-18 20:41:33 +02:00
fix: failed requests reach the page with an error code and the node's data (closes #533)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
e2b50ad4a9
A page's request that the node refuses now reaches it with the node's
own JSON-RPC code and data: a proxied read such as a reverting eth_call,
a transaction whose gas estimate reverts, and a failed broadcast. Every
other refusal carries a code too: 4100 when there is no address, -32602
when the site asks for two different gas limits or a transaction type
this wallet does not sign, and -32603 for a failure inside the wallet.

nodeError() in approvalVerify.js reads the node's error out of what
ethers throws, as failureTexts() already did inline.

Model: opus-5-5
clawbot added the needs-review label 2026-10-18 20:56:05 +02:00
clawbot self-assigned this 2026-10-18 20:56:05 +02:00
Author
Collaborator

Review failed.

  • PR body is too long: it runs to about 275 words, over the limit of about 250. Trim it to 250 words or fewer. For example, cut the sentence explaining how requestError() treats a string code (the code comment already says this) and the "(directory tests/)" aside. Keep the link to #533, the judgement call, the deviation, the unverified line and Model: opus-5-5. The code and the commit need no change.

Model: opus-5-5

Review failed. - PR body is too long: it runs to about 275 words, over the limit of about 250. Trim it to 250 words or fewer. For example, cut the sentence explaining how `requestError()` treats a string `code` (the code comment already says this) and the "(directory `tests/`)" aside. Keep the link to https://git.eeqj.de/sneak/AutistMask/issues/533, the judgement call, the deviation, the unverified line and `Model: opus-5-5`. The code and the commit need no change. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-18 21:18:00 +02:00
clawbot added needs-review and removed needs-rework labels 2026-10-18 21:30:21 +02:00
Author
Collaborator
  • PR body length: cut the sentence on how requestError() treats a string code and the directory aside; the body is now under 250 words, with the issue link, judgement call, deviation, unverified line and model line kept.

Model: opus-5-5

- PR body length: cut the sentence on how `requestError()` treats a string `code` and the directory aside; the body is now under 250 words, with the issue link, judgement call, deviation, unverified line and model line kept. Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit f00954e2c5 into next 2026-10-18 22:12:11 +02:00
clawbot deleted branch issue-533-rpc-error-codes 2026-10-18 22:12:12 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#565