[Bug]: page.goto never returns for a load started as a newer service worker takes over (Chromium)

オープン
#44,287 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
12/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, typescript
領域
testing-qa

調査の方向性

The hang sits in the Chromium driver's handling of Page.navigate when a service worker takes over mid-load, so start from the navigation code in the Chromium backend of the playwright repository and the protocol log in the reproduction repo (protocol-log-hung-run.txt). Run repro.mjs repeatedly to reproduce it, then compare against the direct DevTools protocol scenario. Done would mean page.goto resolves in the takeover case without changing the reproduction's expected timings.

索引モデルが issue の本文から書いたものです。

説明

Version

1.65.1 (latest release); also 1.66.0-alpha-2026-11-20 (next)

Steps to reproduce
  1. Clone https://github.com/MorrisonWill/playwright-sw-takeover-goto-hang
  2. npm install
  3. npx playwright install chromium
  4. for i in 1 2 3 4 5 6 7 8 9 10; do node repro.mjs; done
  5. Each run prints loaded /after in N ms (exit 0) or the load did not finish: TimeoutError: page.goto: Timeout 15000ms exceeded. (exit 1). About half or more of the runs hang.

repro.mjs is one file with no dependency besides playwright-core. It serves a tiny site whose service worker answers page loads from navigation preload, else fetch, else an offline page. Tab one starts a load the server holds, so worker 1 stays busy. The server then serves worker 2, which installs and waits (it called skipWaiting). When the held load is answered, worker 2 takes over and worker 1 is stopped. A page.goto started in tab two at that moment is the one that hangs.

Expected behavior

page.goto(origin + "/after") resolves once the page loads (worker 2 answers it, or the browser falls back to the network), as it does every time when the same steps are driven over the DevTools protocol without Playwright.

Actual behavior

page.goto never returns. Playwright's Page.navigate gets no answer until the browser is closed (then net::ERR_ABORTED), the frame never commits, and the Page object stops working: page.evaluate fails with "Target page, context or browser has been closed", although no close event is emitted and the page is no longer in context.pages().

The navigation preload response for that load arrives (200, loading finished) while it hangs. Chromium reports the old worker's target as crashed (Inspector.targetCrashed), which it does on every takeover when a client is attached, hang or not.

How often, same scenario:

Driver The load hangs
repro.mjs, Playwright 1.65.1, Ubuntu 24.04, Node 24 5 of 10
repro.mjs, Playwright 1.65.1, a second machine (Arch-based Linux 7.2, Node 26) 7 of 10
Playwright 1.65.1, page.goto, in a fuller probe 6 to 7 of 10, and 16 of 20
Playwright 1.66.0-alpha-2026-11-20, page.goto 5 of 10
Playwright 1.65.1 with PLAYWRIGHT_DISABLE_SERVICE_WORKER_NETWORK=1 3 of 10
The DevTools protocol directly (own WebSocket, Target.createTarget, Page.navigate, Page.loadEventFired) 0 of 12
Directly, auto-attached to all targets (Target.setAutoAttach, flatten) 0 of 15
Directly, auto-attached with waitForDebuggerOnStart: true, each target resumed with Runtime.runIfWaitingForDebugger 0 of 15
As above, and page-level service worker sessions detached at once 0 of 15
As above, and Network.enable on pages and workers 0 of 15

Under Playwright, the same load started other ways does not hang (20 runs each, in ways-to-load.txt): page.evaluate(() => location.href = url) then page.waitForURL(url, { waitUntil: "load" }): 0 of 20; a context.newCDPSession(page) doing Page.navigate and waiting for Page.loadEventFired: 0 of 20. A locator.click() on a link that navigates across the same takeover hung once in 65 rounds ("waiting for scheduled navigations to finish").

From DEBUG=pw:protocol of a run that hangs (the whole log is protocol-log-hung-run.txt in the repository; session 612083F7... is the second tab, 7041D190... is worker 1):

20:28:00.958Z SEND {"id":79,"method":"Page.navigate","params":{"url":"http://127.0.0.1:40365/after","frameId":"8EF0890A...","referrerPolicy":"unsafeUrl"},"sessionId":"612083F7..."}
20:28:00.959Z RECV Page.frameStartedNavigating {"frameId":"8EF0890A...","url":"http://127.0.0.1:40365/after","navigationType":"differentDocument"}
20:28:00.960Z RECV Network.requestWillBeSent (the navigation, loader 99073655...)
20:28:00.965Z RECV Network.requestWillBeSent {"requestId":"preload-9", ... "/after"} (navigation preload, on worker 1's session)
20:28:00.965Z RECV Network.responseReceived {"requestId":"preload-9", "status":200}
20:28:00.965Z RECV Network.loadingFinished {"requestId":"preload-9"}
20:28:00.967Z RECV {"method":"Inspector.targetCrashed","params":{},"sessionId":"7041D190..."}   (worker 1)
20:28:00.967Z RECV Target.detachedFromTarget {"sessionId":"7041D190...","targetId":"571988D4..."}
   ... service worker targets attached and detached (worker 2) ...
   (nothing for frame 8EF0890A... after this: no frameNavigated, no commit, no load)
20:28:15.968Z SEND Runtime.evaluate ... (the test's own check, which then fails: target closed)
20:29:20.202Z RECV {"id":79,"result":{"frameId":"8EF0890A...","loaderId":"99073655...","errorText":"net::ERR_ABORTED"}}   (only when the browser is closed)
Additional context

Found while making an installed-app (PWA) end-to-end test reliable: it failed in about 3 of 50 CI runs at a page.goto started while a deploy brought in a new worker. The site's own worker is not the cause, since the direct protocol runs above load every time. I did not find an existing issue for this; the nearest are WebKit and Firefox navigation hangs.

I do not intend to work on a fix myself. The investigation and this report were prepared with the help of an AI coding agent; the reproduction was run on two machines and the numbers above are from those runs.

Environment
System:
  OS: Linux 6.8 Ubuntu 24.04 (x64); also Linux 7.2, Arch-based (x64)
Binaries:
  Node: 24.22.2; also 26.12.0
  npm: 11.20.0
npmPackages:
  playwright-core: 1.65.1
Browser:
  Chromium 1255 from Playwright's download (Chrome for Testing 159.0.8154.6), headless
主要言語
TypeScript
スター
100k
フォーク
6.9k
平均マージ
16時間 8分
マージ済み PR(30日)
281

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/playwright のほかの issue

microsoft/playwright の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。