MetaMask / MetaMask/metamask-extension

[Bug]: Activity - Race condition where 2 websocket connections are created subscribing to the same channel

Open
#45,965 2 comments 0 reactions 0 assignees View on GitHub
area-activity Sev2-normal team-assets type-bug
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

### Describe the bug

This issue has been spotted as a flaky failure in the websocket account activity tests.
We can see that sometimes, there are 2 ws connections created instead of one, making this assert to timeout:
`await waitForAccountActivityWsConnections(driver, 1);`

In the logs, we can see:
```
[AccountActivity Mock] Session created: sessionId=mock-sid-1
[AccountActivity Mock] Session created: sessionId=mock-sid-2
```

and both connections subscribe to the same channel:
`channels=account-activity.v1.eip155:0:0x5cfe73b6021e818b776b421b1c4db2474086a7e1`

### Expected behavior

Just 1 websocket connection

### Screenshots/Recordings

Image

### Steps to reproduce

For debugging, check ci logs:
- https://github.com/MetaMask/metamask-extension/actions/runs/33561579982/job/100037015284
- https://github.com/MetaMask/metamask-extension/actions/runs/33515864472/job/99884996205

### Error messages or log output

```shell

```

### Where was this bug found?

Internal release testing

### Version

main

### Build type

None

### Browser

Chrome

### Operating system

Linux

### Hardware wallet

_No response_

### Additional context

_No response_

### Severity

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the websocket account activity tests and the waitForAccountActivityWsConnections(driver, 1) helper, then compare the referenced CI logs to reproduce the flaky behavior. Done means the test consistently observes one websocket connection subscribing to the account activity channel, without timing out.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.