how-to administratorintegrator

Withdraw the applicant portal’s service worker

Summary

The applicant portal has a service worker. This is a script that the browser keeps on the applicant’s device, so the portal opens with no connection (D71, docs/specs/2026-10-07-offline-portal.md §4.7). The worker answers some requests before the server does. A defect in the worker can therefore stay on a device after you deploy a repair. This runbook withdraws the worker from every device that opens the portal. It does not delete the applicants’ device copies of their drafts.

When to use it

Use it when a portal release has a defect in the worker itself. Examples: the portal opens an old page with a connection, or a stored answer is wrong.

Do not use it for a defect in a page. A page navigation goes to the server first, so a repaired page reaches each device at its next page load.

What the switch does

A build with VITE_PORTAL_WORKER=remove changes two files:

  1. sw.js becomes a worker that installs at once and unregisters itself. It deletes every stored response and reloads each portal tab that it served.
  2. The portal page registers no worker. It unregisters the worker that it finds and deletes every stored response.

The device copies of the drafts are in IndexedDB, not in a stored response. They stay. The portal then needs a connection, as it did before D71.

Procedure

  1. Set the variable for the portal build. The build reads it at build time. For the image, pass it as a build argument. The Dockerfile portal stage declares it:

    docker build --build-arg VITE_PORTAL_WORKER=remove .
    

    For a local build:

    cd frontend/portal && VITE_PORTAL_WORKER=remove npm run build
    

    A .env file with the same line also works. The page and sw.js read the same value.

  2. Check the output before you release it:

    grep -q 'registration.unregister' frontend/portal/dist/sw.js && echo "withdrawal worker"
    
  3. Release and deploy the image as usual.

  4. Open the portal in a browser that had the worker. Load the page two times. Open the browser’s developer tools, then the “Application” panel. Check that the “Service workers” list for the portal is empty, and that “Cache storage” is empty.

    It takes two loads. During the first load, the old worker still serves the page, and its rules store the boot answers again. The second load has no worker, and the page deletes them. A check in Chrome on 2026-10-08 showed this order.

Restore the worker

Build without the variable, then release and deploy. The next page load registers the worker again, and it stores the pages again.

Evidence

CI builds the switch on every run of the frontend workflow. The portal’s step “Product chrome is compiled into the build output, and the worker exists” checks the switch. It fails if the switch no longer writes a worker that unregisters itself.