Docker Build and Publish / build-and-push (push) Failing after 10s
The service worker precaches index.html together with its response headers, so a server-only change never reaches an installed client: the client build is byte-identical, the precache manifest is unchanged, and the worker has no reason to update. That is why the CSP fix in 1.6.1 did not reach a browser that already had the app cached — it kept replaying a cached shell carrying the old, broken CSP, indefinitely. The release version is now compiled into the client, which makes every release change the bundle hash, hence index.html, hence its precache revision, hence sw.js itself — the bytes browsers compare to decide whether to update. Verified by bumping only the version: index-DYufL2Fa.js -> index-60N_3d5j.js, with the new name carried into the sw.js manifest. It also surfaces in the footer, so the deployed version is visible without digging through devtools. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011uBWhwV3wFQ5MBCcMHHem7
35 lines
961 B
TypeScript
35 lines
961 B
TypeScript
import {StrictMode} from 'react';
|
|
import {createRoot} from 'react-dom/client';
|
|
import App from './App.tsx';
|
|
import { ErrorBoundary } from './components/ErrorBoundary';
|
|
import './index.css';
|
|
import { registerSW } from 'virtual:pwa-register';
|
|
|
|
// Register service worker with automatic updates
|
|
// and a periodic check every hour to ensure long-running sessions stay fresh.
|
|
const updateSW = registerSW({
|
|
onRegistered(r) {
|
|
if (r) {
|
|
// Check for updates every hour
|
|
setInterval(() => {
|
|
r.update();
|
|
}, 60 * 60 * 1000);
|
|
console.log(`[PWA] v${__APP_VERSION__} registered; hourly update checks enabled.`);
|
|
}
|
|
},
|
|
onNeedRefresh() {
|
|
console.log('[PWA] New content available, reloading...');
|
|
},
|
|
onOfflineReady() {
|
|
console.log('[PWA] App is ready for offline use.');
|
|
}
|
|
});
|
|
|
|
createRoot(document.getElementById('root')!).render(
|
|
<StrictMode>
|
|
<ErrorBoundary>
|
|
<App />
|
|
</ErrorBoundary>
|
|
</StrictMode>,
|
|
);
|