MetaMask / MetaMask/metamask-extension
SubscriptionsController startup race: '[getSubscriptions] Failed to make request' during e2e/app startup
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
### Summary
`getSubscriptions` intermittently fails during app/extension startup with:
```
[getSubscriptions] error -32603, undefined, Failed to make request. Failed to get subscriptions (url: https://subscription.api.cx.metamask.io/v1/subscriptions)
```
### Where it comes from
- `ShieldSubscriptionProvider` wraps the entire router (`ui/pages/index.js`), so it mounts on every page.
- It evaluates Shield cohort eligibility via `useSubscriptionEligibility` (`ui/hooks/subscription/useSubscription.ts`), which dispatches `getSubscriptions()` as soon as the wallet is signed in and unlocked.
- The background subscription-controller throws `SubscriptionServiceError: Failed to make request` from its fetch wrapper when the HTTP call fails, which is marshalled back to the UI as JSON-RPC `-32603`.
### Impact
- This is a startup race and is unrelated to any specific feature/page. In e2e it surfaces as a console error and forces specs to add `ignoredConsoleErrors: ['getSubscriptions']` (see `test/e2e/tests/state-persistence/state-persistence.spec.ts` and `test/e2e/tests/tokens/asset-sticky-actions.spec.ts`).
### Ask
- Investigate/harden the subscriptions startup fetch (retry/backoff, or gate the request until auth/session is fully ready) so it doesn't error during startup.
- Once fixed, remove the `ignoredConsoleErrors: ['getSubscriptions']` suppressions that reference this issue.
### Owner
`@MetaMask/web3auth` (Shield / subscription), per CODEOWNERS.
### Screenshot
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ui/hooks/subscription/useSubscription.ts and the ShieldSubscriptionProvider mounting in ui/pages/index.js, then trace the background subscription-controller fetch wrapper. Reproduce the startup error in the referenced state-persistence and tokens e2e specs, harden the startup request, and remove the matching ignoredConsoleErrors suppressions once those tests no longer report getSubscriptions failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100