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

Đang mở
#44,287 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
12/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, typescript
Lĩnh vực
testing-qa

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
TypeScript
Star
100k
Fork
6.9k
Merge trung bình
16 giờ 8 phút
Pull request đã merge (30 ngày)
281

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/playwright

Tất cả issue của microsoft/playwright

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.