Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: serviceworker event never emitted when a Manifest V3 extension's service worker stops and restarts #39475

@shairoth12

Description

@shairoth12

Version

1.58.0

Steps to reproduce

Reproduction repository: https://github.com/shairoth12/playwright-sw-repro

  1. Clone the repo and follow the README to install and run
  2. The test launches a persistent context with a simple MV3 extension
  3. It grabs the initial service worker and records a startTime global from the SW's scope
  4. It forces a stop → start cycle via the ServiceWorker CDP domain
  5. It waits for a new serviceworker event (registered before the stop/start)
  6. It evaluates startTime in the new worker to confirm a fresh context

Expected behavior

context.waitForEvent('serviceworker') resolves with a new Worker object after the stop/start cycle, and evaluating in it returns a startTime greater than the original.

Actual behavior

waitForEvent('serviceworker') times out — the event is never emitted. The original Worker reference is still in context.serviceWorkers() but its execution context is stale; any evaluate() call throws.

Additional context

Chrome reuses the same CDP target ID when a Manifest V3 service worker restarts, so no Target.attachedToTarget event is fired and Playwright never learns a new worker exists. This is reproducible with an explicit CDP stop/start cycle as well as with chrome.runtime.reload().

This is a reopening of a previous issue: #27015

A fix is introduced in #39476

Environment

- OS: macOS 15.3.1, Apple M1 Max
- Browser: Chromium (bundled with Playwright)
- Language: Node.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions