Skip to content

fix(ramps-controller): expose circuit breaker error key#8596

Draft
saustrie-consensys wants to merge 3 commits intomainfrom
saustrie-consensys/TRAM-3475-circuit-breaker-open-error
Draft

fix(ramps-controller): expose circuit breaker error key#8596
saustrie-consensys wants to merge 3 commits intomainfrom
saustrie-consensys/TRAM-3475-circuit-breaker-open-error

Conversation

@saustrie-consensys
Copy link
Copy Markdown
Contributor

@saustrie-consensys saustrie-consensys commented Apr 27, 2026

Explanation

When repeated upstream failures trip the service-policy circuit breaker, RampsController can receive the internal Cockatiel message Execution prevented because the circuit breaker is open.

The first version of this fix replaced that message with hardcoded user copy inside core, but that puts localization responsibility in the wrong layer.

This PR instead keeps core out of copy ownership by:

  • exporting RAMPS_ERROR_CODES.CIRCUIT_BREAKER_OPEN
  • attaching errorKey metadata to classified request/resource failures
  • rethrowing classified errors with the same errorKey so clients can localize them
  • preserving the original technical message for logging/debugging rather than replacing it with English UI copy

This covers the shared executeRequest path used by ramp quote/resource calls and the native Transak quote path, adds regression coverage for request-state, resource-state, selector, and rethrow behavior, and updates the @metamask/ramps-controller changelog.

References

Testing

  • yarn workspace @metamask/ramps-controller test
  • yarn workspace @metamask/ramps-controller messenger-action-types:check
  • yarn eslint packages/ramps-controller/src/RampsController.ts packages/ramps-controller/src/RampsController.test.ts packages/ramps-controller/src/RequestCache.ts packages/ramps-controller/src/selectors.ts packages/ramps-controller/src/selectors.test.ts packages/ramps-controller/src/index.ts packages/ramps-controller/src/rampsErrorCodes.ts
  • yarn tsc --noEmit -p packages/ramps-controller/tsconfig.json (still fails in this checkout due existing referenced-build / monorepo type issues, including TS6305 build-artifact errors and unchanged pre-existing TransakService.ts type errors)

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 communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@saustrie-consensys saustrie-consensys changed the title fix(ramps-controller): replace circuit breaker error with retry copy fix(ramps-controller): expose circuit breaker error key Apr 27, 2026
Comment thread packages/ramps-controller/src/RampsController.ts Fixed
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