Skip to content

build: stamp the service worker after the public directory is recopied - #15553

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.52from
HouMinXi:fix/sw-stamp-after-public-recopy
Oct 6, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.52from
HouMinXi:fix/sw-stamp-after-public-recopy

Conversation

@HouMinXi

@HouMinXi HouMinXi commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Summary

stampServiceWorkerBuildId runs inside copyStaticAndPublic, but copyNativeAssetsAndExtraModules copies public/ again afterwards with force: true (the public directory entry in EXTRA_MODULE_ENTRIES). That second copy overwrites the stamped sw.js with the source file, so the image ships const CACHE_NAME = "omniroute-pwa-v3"; with no build id.

A browser compares the fetched worker's bytes against the installed one, sees no change, and keeps the worker from the previous deploy. That worker requests /_next/static/<old build id>/, which 404s, and the dashboard stays blank on refresh.

This moves the stamp to just after that second copy. Nothing after it touches public/.

Related to #15552

Test plan

  • Built an image with the change. /app/public/sw.js carries the build id (omniroute-pwa-v3-<id>), where the previous image was byte-identical to the source file.
  • The served /sw.js matches.

copyNativeAssetsAndExtraModules copies public/ again with force, which
overwrites the build id that copyStaticAndPublic just wrote into sw.js.
The image then ships the generic cache name, so a browser keeps the
worker from the previous deploy and serves chunks that no longer exist.
Stamp after that second copy.

Signed-off-by: Minxi Hou <houminxi@gmail.com>
@HouMinXi
HouMinXi requested a review from diegosouzapw as a code owner October 5, 2026 09:25
@diegosouzapw
diegosouzapw merged commit fdf397f into diegosouzapw:release/v3.8.52 Oct 6, 2026
44 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants