MetaMask / MetaMask/metamask-extension

[Bug]: Background - Terminate service worker and try to login to the wallet: `Cannot call write after a stream was destroyed`

Open
#35,470 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

regression-prod-13.1.2 regression-prod-13.13.0 Sev2-normal team-extension-platform type-bug
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

Describe the bug

If you terminate service worker and then try to login to the wallet, without refreshing you get the: Cannot call write after a stream was destroyed error in the UI and cannot login.
You can work around the issue just by refreshing the browser, so it's not severe. However, reporting in case this needs to be investitgated further in the context of the infinite loading issues, or if there are Sentry issues which are just that.

This is error appears on the console when you terminate the service worker: Error#1: PortDuplexStream - disconnected

Expected behavior

No response

Screenshots/Recordings
Image

https://github.com/user-attachments/assets/818b6b94-3d79-4932-8421-47e0a30b96ec

Steps to reproduce
  1. Open MetaMask in full view and log in
  2. Open a new tab and go to chrome://serviceworker-internals/?devtools
  3. Look for the MM extension Id
  4. Click Stop on the service worker for your extension
  5. Go to MetaMask tab
  6. Without refreshing, lock it
  7. Try to unlock it
  8. See error
    (same happens if you try to reveal the priv key )
Error messages or log output

Detection stage

In production (default)

Version

13.1.2

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

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.

Research direction

Start by reproducing the service-worker termination and wallet unlock steps in Chrome, then trace the PortDuplexStream - disconnected and Cannot call write after a stream was destroyed errors. Done means locking, unlocking, and revealing the private key work without refreshing after the service worker is stopped.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.