mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 06:53:14 +00:00
fix: switch PWA service worker to autoUpdate to avoid stale bundles after deploy (#94)
* Standardize remaining Node pins on Node 24 Refs: #40 - Bump sandbox Dockerfile to Node 24.18.0-1nodesource1 + setup_24.x - Move Playwright E2E job to node-version: "24" (quoted) - Update INSTALLATION.md to recommend Node 24 * Switch PWA service worker to autoUpdate to avoid stale bundles after deploy VitePWA's registerType: 'prompt' kept the new service worker waiting indefinitely because no update-prompt UX was wired. Returning visitors kept receiving the old precached app shell and hashed chunks. 'autoUpdate' uses skipWaiting + clientsClaim so a deploy takes over on the next navigation. Refs: #86 * Update PWA registration comment to match autoUpdate behavior The previous comment described prompt-mode behavior, but the SW is now configured with autoUpdate. Document the reload tradeoff explicitly so the comment no longer contradicts the VitePWA setting. Refs: #86 --------- Co-authored-by: amoussa1229 <166072409+amoussa1229@users.noreply.github.com>
This commit is contained in:
parent
98fa659303
commit
2335ac59c0
2 changed files with 7 additions and 4 deletions
|
|
@ -3,9 +3,12 @@ import { StrictMode } from "react"
|
|||
import { hydrateRoot } from "react-dom/client"
|
||||
import { registerSW } from "virtual:pwa-register"
|
||||
|
||||
// prompt mode: a new SW installs in the background and takes over on the next
|
||||
// load, so deploys never reload a tab mid-agent-run. Skip in dev — the SW
|
||||
// precaches production-only build artifacts that 404 against the dev server.
|
||||
// autoUpdate: vite-plugin-pwa generates a SW that calls skipWaiting and
|
||||
// clientsClaim, so a new deploy activates for existing tabs. Open dashboard
|
||||
// tabs may reload when the service worker takes over; this is acceptable for
|
||||
// a dev/internal dashboard where silent updates are preferred over stale
|
||||
// bundles. Skip in dev — the SW precaches production-only build artifacts that
|
||||
// 404 against the dev server.
|
||||
if (import.meta.env.PROD) {
|
||||
registerSW()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ const config = defineConfig({
|
|||
tanstackStart({ spa: { enabled: true } }),
|
||||
VitePWA({
|
||||
injectRegister: false,
|
||||
registerType: "prompt",
|
||||
registerType: "autoUpdate",
|
||||
outDir: ".output/public",
|
||||
devOptions: {
|
||||
enabled: true,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue