Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RpcService: Regard node-fetch errors as retriable #5298

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Feb 6, 2025

Explanation

Currently we have tests for middleware to verify that requests get retried when certain errors are thrown. In a future commit we will replace the retry logic in these middleware with RpcService, and when this happens the aforementioned tests will break. This is because we are using Nock to force the request to throw errors, and in tests we use node-fetch to polyfill the fetch function, and node-fetch errors are not regarded as retriable by RpcService.

This commit adjusts RpcService to treat node-fetch errors as retriable (but making sure to exclude errors from Nock itself, since they will also be manifested as node-fetch errors).

References

This is a prerequisite for #4991.

Changelog

(N/A; developer-only change since RpcService is still internal.)

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

We use `node-fetch` internally for testing. This library produces its
own error messages whenever a request cannot be initiated, so we need to
account for it within the RpcService retry logic. However, we need to
make sure to exclude errors from Nock so we don't get weird results in
tests.
Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@types/[email protected] None 0 11.9 kB types

View full report↗︎

@mcmire mcmire marked this pull request as ready for review February 6, 2025 21:07
@mcmire mcmire requested review from a team as code owners February 6, 2025 21:07
@@ -191,7 +379,7 @@ describe('RpcService', () => {
const jsonRpcRequest = {
id: 1,
jsonrpc: '2.0' as const,
method: 'eth_chainId',
method: 'eth_unknownMethod',
Copy link
Contributor Author

@mcmire mcmire Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered while making these changes that these tests were actually incorrect but were not failing. Considering that they created Nock errors I decided to fix them at the same time.

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

Successfully merging this pull request may close these issues.

1 participant