Fix JSON-RPC handler losing revert data for non-ProviderError errors#8061
Merged
ChristopherDedominici merged 2 commits intomainfrom Mar 16, 2026
Merged
Fix JSON-RPC handler losing revert data for non-ProviderError errors#8061ChristopherDedominici merged 2 commits intomainfrom
ChristopherDedominici merged 2 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: c03f647 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes JSON-RPC error handling so revert metadata (transactionHash / revert data) is preserved even when the thrown error is not a ProviderError (e.g., Solidity-style errors), ensuring revert assertions continue to work over HTTP/WebSocket.
Changes:
- Extract
txHashandreturnDatafrom the original error before wrapping non-ProviderErrorerrors intoInternalError. - Add a unit test that simulates a non-
ProviderErrorcarrying.dataand.transactionHashand asserts the JSON-RPC response preserves both.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| v-next/hardhat/src/internal/builtin-plugins/node/json-rpc/handler.ts | Moves revert data extraction ahead of non-ProviderError wrapping to avoid losing metadata. |
| v-next/hardhat/test/internal/builtin-plugins/node/json-rpc/handler.ts | Adds coverage ensuring revert metadata survives the JSON-RPC HTTP layer for non-ProviderError errors. |
You can also share your feedback on Copilot code review. Take the survey.
schaable
approved these changes
Mar 13, 2026
alcuadrado
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
(txHash, returnData)for non-ProviderError errors (e.g. SolidityError)This bug only affects the Hardhat node (HTTP) because it is exclusive to the JSON-RPC serialization path, whereas in-process EDR passes errors as raw JavaScript objects, bypassing serialization entirely.
Problem
_handleErrorinhandler.tswrapped non-ProviderError errors in InternalError before callingextractTxHash()andextractReturnData(). Since InternalError doesn't carry .data or .transactionHash, all revert information was lost in the JSON-RPC response.This broke every revert-checking assertion (.revertedWithCustomError(), .revertedWith(), .revertedWithPanic(), etc.) when running tests against hardhat node over HTTP/WebSocket. In-process EDR tests were unaffected.
Fix
Move the two extraction calls above the wrapping to preserve the info.