From bb446c717f92ef912f5000ddc757b9d1071120dc Mon Sep 17 00:00:00 2001 From: Jonathan Sykes Date: Wed, 7 Oct 2026 23:58:29 +0800 Subject: [PATCH] Keep single-tag rollback on the legacy worker path --- server/asset-manifest.js | 2 ++ server/asset-manifest.test.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/server/asset-manifest.js b/server/asset-manifest.js index 22e4384..6df5494 100644 --- a/server/asset-manifest.js +++ b/server/asset-manifest.js @@ -27,6 +27,8 @@ export function stampIndex(source, files, { hashing = true, buildTag = '__BUILD_ } export function createAssetManifest(publicDir = './public', { hashing = true, buildTag: override, assetSync = true } = {}) { + // Single-tag URLs cannot be verified against per-file URL hashes. + assetSync = hashing && assetSync; const bytes = new Map(); const legacy = createHash('sha256'); function walk(dir, prefix = '') { diff --git a/server/asset-manifest.test.js b/server/asset-manifest.test.js index 0b03375..c09a7a3 100644 --- a/server/asset-manifest.test.js +++ b/server/asset-manifest.test.js @@ -68,3 +68,7 @@ test('sync rollback changes build identity and injected worker byte hash', () => expect(on.manifest.buildTag).not.toBe(off.manifest.buildTag); expect(off.manifest.files['/sw.js'].h).toBe(hash(off.sw)); })); +test('single-tag hashing rollback also selects the legacy worker', () => fixture(dir => { + writeFileSync(join(dir,'sw.js'), "const VERSION = typeof __BUILD_TAG__ !== 'undefined' ? __BUILD_TAG__ : 'old'; const SYNC = typeof __ASSET_SYNC__ !== 'undefined' ? __ASSET_SYNC__ : true;"); + expect(createAssetManifest(dir,{hashing:false}).sw).toContain('const SYNC = false'); +}));