-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Version
1.58.0
Steps to reproduce
Reproduction repository: https://github.com/shairoth12/playwright-sw-repro
- Clone the repo and follow the README to install and run
- The test launches a persistent context with a simple MV3 extension
- It grabs the initial service worker and records a
startTimeglobal from the SW's scope - It forces a stop → start cycle via the
ServiceWorkerCDP domain - It waits for a new
serviceworkerevent (registered before the stop/start) - It evaluates
startTimein 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