[Bug]: Server browser tab silently closes when a site's service worker calls navigator.setAppBadge #21022
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/web
Steps to reproduce#
- Serve these two files from any static server, for example
python3 -m http.server 8765
index.html
<!doctype html><p id=s>loaded</p>
<script>
navigator.serviceWorker.register("sw.js")
.then(() => navigator.serviceWorker.ready)
.then(r => { r.active.postMessage("badge"); s.textContent = "sw posted" })
</script>
sw.js
self.addEventListener("install", () => self.skipWaiting())
self.addEventListener("activate", e => e.waitUntil(self.clients.claim()))
self.addEventListener("message", e => e.waitUntil(navigator.setAppBadge(3).catch(() => {})))
- Open
http://127.0.0.1:8765/in an environment-hosted browser tab, from the browser panel or withpreview_open - The tab disappears within about a second
Real-world trigger: the signed-in Fluxer web client. Its service worker handles APP_UPDATE_BADGE by calling navigator.setAppBadge, so the tab closes right after sign-in, including on OAuth authorize pages on that site
Expected behavior#
The page keeps running and setAppBadge resolves or rejects. If the renderer does die, the tab stays open and shows that its page crashed
Actual behavior#
Chromium kills the renderer for a bad IPC message because chrome-headless-shell registers no BadgeService binder for service workers. Playwright then emits crash, and apps/server/src/preview/ServerBrowser.ts drops the tab with page.on("crash", () => dropTab(tab, true)) (line 867 on main @ 07cb90286). The panel and any agent tab vanish with no message, and the next agent call fails with PreviewAutomationTabNotFoundError
| Case | Result |
|---|---|
Service worker calls setAppBadge, bundled headless shell 154.0.8037.92 | Crash |
| Same, headless shell 156.0.8078.4 | Crash |
| Same, full Chrome for Testing 156.0.8078.4 headless | No crash |
Page itself calls setAppBadge, headless shell | No crash |
Stub via addInitScript (pages only) | Crash |
Stub via Playwright serviceworker event and worker.evaluate | Crash, the worker restarts first |
| Stub via CDP auto-attach, paused at worker start | No crash |
Impact#
Blocks work completely
Version or commit#
0.1.1-nightly.20261017.3272
Environment#
Ubuntu Linux (kernel 7.0.0), headless server running t3 serve, server browser chrome-headless-shell 154.0.8037.92, Node 24.21.0
Logs or stack traces#
ERROR:content/browser/renderer_host/render_process_host_impl.cc:6348] Terminating render process for bad Mojo message: Received bad user message: No binder found for interface blink.mojom.BadgeService for the service worker scope
ERROR:content/browser/bad_message.cc:29] Terminating renderer for bad IPC message, reason 123
# server.trace.ndjson, no preview.close RPC from a client
PreviewAutomationBroker.focusHost Success
PreviewManager.close Success
PreviewToolkit.invoke Failure PreviewAutomationTabNotFoundError
Screenshots, recordings, or supporting files#
No response
Workaround#
None inside T3. Outside it, a Playwright persistent context with serviceWorkers: "block" and the profile's Service Worker folder cleared keeps the site running
Fixes that would work in T3:
- Pause service workers at start with
Target.setAutoAttach(waitForDebuggerOnStart: true,flatten: true, service worker filter), replaceWorkerNavigator.prototype.setAppBadgeandclearAppBadgewith resolved no-ops, then callRuntime.runIfWaitingForDebugger. Verified against the repro - Run full Chrome headless instead of
chrome-headless-shell. Verified against the repro and Fluxer - Independently, keep a crashed tab and show a crashed state with Reload instead of dropping it silently
Neonsy(GitHub profile, opens in a new tab) added labelsbug
Neonsy(GitHub profile, opens in a new tab) added labelsneeds-triage
juliusmarminge added labelsaccepted
juliusmarminge added labelsvia-triage
juliusmarminge removed labelsneeds-triage
@juliusmarminge Thanks for accepting the silent drop. Some follow-up on the upstream part
Upstream gap confirmed. Chromium already fixed the page-level version of this in 40133759 (formerly crbug 1090429) by adding a no-op
StubBadgeServiceto headless. On currentmain,headless/lib/browser/headless_content_browser_client.ccregisters that stub only inRegisterBrowserInterfaceBindersForFrame. Nothing registers it for service workers, which matches the repro: Page-levelsetAppBadgeworks, service-workersetAppBadgekills the renderer. It still reproduces on the latest Canarychrome-headless-shell158.0.8110.0Why the crashed state alone won't unblock affected sites. Keeping the tab and showing it as crashed is a clear improvement, but Reload crashes it again as soon as the service worker sets a badge. Sites like the signed-in Fluxer client stay unusable in the server browser until either Chromium or T3 avoids the call
Since T3 ships
chrome-headless-shelland an upstream fix will take a while to reach a release, would you take this as a mitigation in T3? Pause service workers at start withTarget.setAutoAttach(waitForDebuggerOnStart: true,flatten: true, service worker filter), replaceWorkerNavigator.prototype.setAppBadgeandclearAppBadgewith resolved no-ops, thenRuntime.runIfWaitingForDebugger. Verified against the reproReproduced on current main 70e5e384da on Linux with the supplied two-file fixture served by
python3 -m http.server 8765. In the real web dev app, enteringhttp://127.0.0.1:8765/in the environment-hosted Browser panel removes its tab and returns the panel to “Open a surface.” The server trace recordsPreviewManager.closeafter navigation. Opening the same fixture through preview automation also makes the tab disappear; the next snapshot returnsPreviewAutomationTabNotFoundError. No matching duplicate found in the paged open-issue check.juliusmarminge closed this
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Thanks for the detailed matrix. Two parts here:
chrome-headless-shellitself; per your table, full Chrome headless doesn't crash. That part belongs with Chromium.ServerBrowser.tshandles Playwright'scrashby callingdropTab(tab, true), which deletes the tab and closes its session. Viewers only get a generic "gone", so the tab vanishes with no crashed state and later agent calls hitPreviewAutomationTabNotFoundError.Keeping this open as a bug for the silent drop.