MetaMask / MetaMask/metamask-extension

[Bug]: Storybook background proxy returns never-resolving promises

Open
#40,105 0 comments 0 reactions 1 assignee View on GitHub

@georgewrmarshall is already working on this.

Since Feb 13, 2026.

INVALID-ISSUE-TEMPLATE
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

## **Description**

The Storybook background proxy in `.storybook/preview.js` returns promises that never resolve or reject, causing stories that await background method calls to hang indefinitely in a loading state.

This was discovered by Cursor bot during review of PR #39539.

## **Technical Details**

**Location**: `.storybook/preview.js` lines 84-86

**Current code**:
```javascript
const proxiedBackground = new Proxy(
{},
{
get(_, method) {
return function () {
// No-op function for background calls in Storybook
return new Promise(() => {}); // ❌ This promise never resolves!
};
},
},
);
```

**Problem**:
- `new Promise(() => {})` creates a promise that never resolves or rejects
- Any story that calls `submitRequestToBackground()` and awaits the result will hang forever
- Stories cannot continue with fallback/default behavior

**Severity**: Medium
- Stories relying on background calls will be stuck in perpetual loading state
- Affects developer experience when working with stories that interact with background methods

**Proposed Fix**:
```javascript
get(_, method) {
return function () {
// No-op function for background calls in Storybook - immediately resolves
return Promise.resolve();
};
}
```

This will:
- Allow background calls to complete immediately
- Let stories continue with their fallback/default behavior
- Maintain the no-op behavior (no actual work is done)
- Prevent hanging/loading states

## **Threat Modeling Framework**

**What are we working on?**
- Fixing the Storybook background proxy to return resolved promises instead of never-resolving ones

**What can go wrong?**
- Some stories might expect the promise to never resolve (unlikely)
- Some stories might not handle resolved promises properly
- Need to verify stories still work correctly after the change

**What are we going to do about it?**
- Change `new Promise(() => {})` to `Promise.resolve()`
- Test affected stories to ensure they still render correctly
- Verify no stories are stuck in loading states

**Did we do a good job?**
- Stories load properly without hanging
- No regressions in Storybook functionality
- Developer experience is improved

## **Acceptance Criteria**

- [ ] Update `.storybook/preview.js` to return `Promise.resolve()` instead of `new Promise(() => {})`
- [ ] Run Storybook locally and verify stories load without hanging
- [ ] Run `yarn storybook` and manually test a few stories that might call background methods
- [ ] Verify CI Storybook tests pass
- [ ] No regressions in existing story functionality

## **Stakeholder Review**

- [x] Engineering (needed in most cases)
- [x] QA (automation tests are required to pass before merging PRs)

## **References**

- **Found in PR**: https://github.com/MetaMask/metamask-extension/pull/39539
- **Cursor bot comment**: https://github.com/MetaMask/metamask-extension/pull/39539#discussion_r2805182947
- **Code location**: `.storybook/preview.js:84-86`
- **Related PR**: #39539 (Storybook cleanup)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.