Repository navigation
fix: send POST requests past the PWA service worker - #27588
totally-not-ai[bot] wants to merge 6 commits into
Conversation
Chromium can drop the unload beacon of a page that a service worker controls, so the UI of a reloaded page stays open on the server until the heartbeat timeout. The worker serves only GET requests, so a static route now sends POST requests to the network without involving it, in browsers that support static routing. Fixes #27586
Type of change
How to test
Browser support
|
Bundle sizeCompared with the base commit 3c06b37.
The production bundle of |
vaadin-review-bot
left a comment
There was a problem hiding this comment.
Reviewed the changes — left 1 comment.
| Finding | |
|---|---|
| 📐 | The waiting step that stands in for an assertion does not handle TimeoutException |
| // An unload beacon cannot be observed from a page, so the UIDL | ||
| // requests of the reloaded page, POST requests as well, stand in for | ||
| // it. The matched source is empty when the fetch handler served one. | ||
| String sourceTypes = waitUntil(driver -> (String) executeScript( |
There was a problem hiding this comment.
📐 The waiting step that stands in for an assertion does not handle TimeoutException
CONVENTIONS.md (Testing): "When an assertion becomes a wait, catch TimeoutException and fail with the message and the expected and actual values."
The waitUntil here asserts that the reloaded page made a UIDL request at all. If none is recorded — the bootstrap stops issuing one, the URL parameter changes, or the resource timing buffer overflows — the test dies on a bare TimeoutException naming only the lambda, and the carefully worded message on the assertTrue below never prints.
PwaTestIT.java:201 · conventions
There was a problem hiding this comment.
@vaadin-review-bot The wait now catches TimeoutException and fails with a message saying no UIDL request was recorded, listing the resources the reloaded page did request, so the cause is visible without the stack trace.
📦 Snapshot published
Built without running tests. Look at the checks on this pull request before relying on it. Every new commit on this branch republishes it while the How to use it<repository>
<id>vaadin-snapshots</id>
<url>https://maven.vaadin.com/vaadin-prereleases</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-bom</artifactId>
<version>25.5.sw-bypass-post-requests-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- After flow-bom, so that its Flow version wins -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>25.5-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>Replace the application's own |
vaadin-review-bot
left a comment
There was a problem hiding this comment.
✅ Nothing to flag — the changes look good.
vaadin-review-bot
left a comment
There was a problem hiding this comment.
✅ Nothing to flag — the changes look good.
Artur-
left a comment
There was a problem hiding this comment.
Could this break something like actual handling of POST requests offline?
|
@Artur- No, it shouldn't. The rule only changes who handles POST requests; nothing in Flow handled them offline before.
So the only POSTs that skip the worker are ones it already passed to the network untouched. I made no code change for this. |
|



Fixes #27586
behavior deviation · flow-server (PWA service worker) · apps with
@PWAon Chromium browsersBackground — service worker static routing. A service worker with a fetch handler receives every request of the pages it controls, even ones it never answers. Static routing (
InstallEvent.addRoutes) lets a worker declare at install time which requests go straight to the network without starting the worker.When a page controlled by the PWA service worker is reloaded in a Chromium browser, the beacon that closes its UI on the server is sometimes lost. The old UI then stays open, with its listeners and any locks, until the heartbeat timeout. Bypassing the service worker for these requests avoids the loss; there was no workaround besides turning off the worker.
Risks:
Context. The worker only routes GET requests (navigations, precache, network-first URLs), so a POST-only rule cannot take away anything it serves. A UIDL-only URL pattern was the alternative, but it would leave push and other POST requests going through the worker for no gain.
installhandler tosw.tsthat adds a static route sending POST requests to the network, ignoring a rejected rulePwaTestITchecking that the UIDL requests of a controlled page are matched to the network sourceARCHITECTURE.mdWorking on behalf of @Artur-