Skip to content

test: Cover isServiceFailure override and Infura failure classification#9169

Merged
cryptodev-2s merged 2 commits into
fb/treat-more-errors-as-service-failuresfrom
fb/treat-more-errors-as-service-failures-tests
Jun 17, 2026
Merged

test: Cover isServiceFailure override and Infura failure classification#9169
cryptodev-2s merged 2 commits into
fb/treat-more-errors-as-service-failuresfrom
fb/treat-more-errors-as-service-failures-tests

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Follow up to #9123 to add the missing test coverage and fix a stale comment. Targets that PR's branch so it merges in before #9123 goes to main.

What this adds

packages/controller-utils (create-service-policy.test.ts):

  • Custom isServiceFailure opens the circuit when the predicate treats the error as a failure, and never opens it when it does not.
  • The predicate is called with the raw error thrown by the service.
  • The default predicate still applies when the option is omitted (breaks on httpStatus >= 500, not on < 500).

packages/network-controller (rpc-service.test.ts):

  • On an Infura endpoint, 400 and 429 do not break the circuit, while 401 and 500 do.
  • A non Infura endpoint with the same config does not break on 401, which proves the Infura predicate is what changes the behavior.

Cover the new `isServiceFailure` override option in `createServicePolicy`
(custom predicate is honored, called with the raw error, and the default
still applies when omitted) and the Infura specific classification in
`RpcService` (400 and 429 do not break the circuit, other errors like 401
and 500 do, and non Infura endpoints are unaffected).

Also fix a stale comment in both predicates that referred to a "code"
property where the check is actually on `httpStatus`.
@cryptodev-2s cryptodev-2s merged commit 02d5510 into fb/treat-more-errors-as-service-failures Jun 17, 2026
375 checks passed
@cryptodev-2s cryptodev-2s deleted the fb/treat-more-errors-as-service-failures-tests branch June 17, 2026 13:17
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.

2 participants