A service worker claimed an open page and aborted its first request
The first request failed while later attempts worked
A conversation practice screen sometimes failed to return a scene on the first attempt. Subsequent attempts completed in about two seconds. The failure appeared roughly once in three attempts, making it look like an intermittent delay. From the user’s perspective, the screen froze when they first tried to use it.
That description captured the visible symptom, but it did not describe what happened to the request. The request was not taking unusually long to finish. It was being aborted.
The distinction mattered because the screen involved an AI call. A missing result made the model and the server reasonable places to investigate. Yet the successful later attempts did not explain the failed first attempt. They showed that the operation could complete, while leaving the first request’s fate unresolved.
The investigation therefore needed to answer a narrower question: did the browser still have a request waiting for a response, or had that request already ended in failure? Until that was measured, “the scene never arrived” could keep directing attention toward the wrong part of the application.
Measurements ruled out the suspected delays
The initial checks covered the model, function loading, server responses, CORS preflight, and a possible page reload. Each was measured rather than accepted as an explanation.
Gemini completed in 0.8–1.2 seconds. Loading the function’s dependencies through require('lib/index.js') took 841 ms. Neither measurement accounted for the observed first-use freeze.
The server was then tested without the browser in the path. Three consecutive calls from Node all returned HTTP 200, taking 1.7–1.9 seconds. This was useful evidence because it separated the server’s ability to return a result from the browser’s handling of that operation. The server-side route completed in those tests; the failing browser interaction still needed an explanation.
The CORS preflight was also measured. OPTIONS requests took 0.21–0.28 seconds. A page reload was another possibility, but the reload marker in sessionStorage had not been set.
These checks did not identify the cause by themselves. They removed specific explanations that had initially seemed plausible. There was no measured model delay matching the freeze, no failed response in the direct Node tests, and no recorded sign that the page had reloaded itself.
At this point, continuing to investigate general server latency would have left the most important evidence uncollected: what happened to the particular browser request that failed.
The request ended before the screen’s timeout
The decisive probe recorded lifecycle events for the affected request alone:
request / requestfinished / requestfailed / response
Its failure summary was:
送った 1 / 返った 0 / 切れた 1 net::ERR_ABORTED 190〜510ms
The summary recorded one request sent, no response returned, and one abort. The failure reason was net::ERR_ABORTED, and the abort occurred within 190–510 ms.
That timing separated the failure from the screen’s own 12-second timeout. The request had already been cut off long before that timeout could explain the missing result. Waiting longer for the same request was not the issue under investigation.
The next step was a control test using the same interaction with service workers blocked. Playwright provided the relevant context option:
browser.newContext({ serviceWorkers: 'block' })
With service workers enabled, the test succeeded in 0 of 5 runs. Every affected request failed with net::ERR_ABORTED, and navigator.serviceWorker.controller was present.
With service workers blocked, the test succeeded in 5 of 5 runs. Every request returned HTTP 200 in 1.7–1.9 seconds.
The control changed the service worker condition while repeating the interaction. Combined with the request lifecycle record, it moved the investigation beyond a vague association between first use and failure. The enabled runs showed an aborted request under service worker control; the blocked runs showed completed responses.
The probe used a fresh browser context for each run and repeated the same sequence: sign in, open the screen, and press the relevant control. It tracked only the request being investigated, including whether it was sent, whether it returned, whether it failed and why, and whether a service worker controlled the page. That kept the evidence attached to the operation that appeared frozen.
Claiming the open page interrupted the fetch
The service worker called self.skipWaiting() during installation and self.clients.claim() during activation. In this case, that combination allowed the worker to take control of an already-open page while a fetch was in progress.
The fetch had started before the worker claimed the page. When control changed, that request failed with net::ERR_ABORTED. This explained why the visible symptom was concentrated around the first interaction after opening the screen.
The corrective change was to stop calling both forms of the claim operation: clientsClaim() and clients.claim(). The installation-time skipWaiting() call could remain so that the new version would not remain in the waiting state. The new version would take effect when the page was next opened.
That choice accepted a later point for the new worker to take control. For this application, preserving the initial request was more important than immediately claiming a page that was already open.
The record also identified an alternative for an implementation that requires immediate control: pair the change with a page reload on controllerchange. That has its own cost when a conversation or user input is already in progress. It was not a reason to treat an immediate reload as a consequence-free replacement.
The scope of the fix extended beyond the conversation practice screen. Other screens that issued requests immediately after opening, including additional AI features and a payment check, could encounter the same interruption. The record reports that those affected flows were fixed as well. The relevant shared behavior was the early request, so the investigation could not end at the first screen where the symptom had been noticed.
Check request outcomes before treating a freeze as latency
The practical lesson is to record how a request ends, alongside how long it takes. A screen with no result does not establish that its request is still running. In this case, the failure reason and elapsed time showed that the request had been aborted within 190–510 ms, well before the application’s timeout.
For a similar symptom, isolate the request that supplies the missing result. Record its request, response, requestfinished, and requestfailed events. Keep the failure reason with the timing so that an aborted operation does not disappear into a general description of slowness.
Then test the same call outside the browser. Here, consecutive successful Node calls established a working server path and gave the browser investigation a concrete comparison. Repeat the browser interaction with service workers blocked to check whether the failure changes under that condition.
Finding clients.claim in another application is a reason to investigate, not a completed diagnosis. The source record explicitly calls for reproduction before modification. An application whose screens do not issue requests immediately after opening may not show this symptom despite having the same setting.
Use a fresh context, repeat the opening interaction, and inspect the particular request. Change the claim behavior where the failure reproduces, then check the other screens that make requests at the same point in their lifecycle. The useful question is whether the request completed or was cut off—not simply whether the user waited without seeing a result.
Further reading
MDN documents Clients.claim() as making the active service worker control all clients within its scope, including pages that loaded before it activated — see MDN: Clients.claim(). That is the mechanism this incident turned on its head: a page's in-flight fetch was issued before the worker claimed it.
clients.claim() is one piece of the service worker lifecycle (install, activate, claim) that this incident turned on its head. Building Progressive Web Apps (Tal Ater) covers that lifecycle in depth, including the claim behavior this post is about.
Advertisement: the book is listed on Amazon. As an Amazon Associate I earn from qualifying purchases.
Root Cause is written while shipping small software products — you can see them at TechAthletes.