fix(preview): avoid stale script chunks when the pack is rebuilt out-of-band#728
Open
bofeng-song wants to merge 1 commit into
Open
fix(preview): avoid stale script chunks when the pack is rebuilt out-of-band#728bofeng-song wants to merge 1 commit into
bofeng-song wants to merge 1 commit into
Conversation
…of-band When Creator and the cli-driven IDE open the same project, they share <project>/temp/programming/packer-driver. Creator recompiling on save mutates that shared store (new chunk hashes, old chunks removed); the cli then serves a stale in-memory import-map / browser-cached chunk that references a removed chunk hash, so the preview fails with SystemJS Error#3 (chunk 404). - scripting-routes: serve pack resources (/scripting/x, /chunks) with Cache-Control: no-store so the browser never keeps a stale chunk / import-map. - live-reload: watch temp/programming/packer-driver; when import-map / resolution-detail-map change (a compile finished, possibly in another process), refresh the in-memory QuickPackLoader (facet.notifyPackDriverUpdated) and trigger a browser reload, so the preview loads a consistent import-map + chunks.
star-e
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When Cocos Creator and the cli-driven IDE open the same project at the same time, both share
<project>/temp/programming/packer-driver. Editing and saving a script that the scene references makes Creator recompile out-of-band, mutating that shared pack store (new chunk hashes, old chunks removed). Opening/refreshing the cli preview then fails with high probability:i.e. a loaded chunk imports a chunk hash that no longer exists (404). Two causes:
QuickPackLoaderstill holds the previous import-map (it doesn't know another process recompiled), andChanges
/scripting/x,/chunks) withCache-Control: no-store, so the browser never keeps a stale chunk or import-map.temp/programming/packer-driver; whenimport-map.json/resolution-detail-map.jsonchange (a compile finished — possibly in another process such as Creator), refresh the in-memory loader viafacet.notifyPackDriverUpdated()and trigger a browser reload, so the preview always loads a consistent import-map + chunks.Notes
temp/packer-driver(does not isolate cli's output); the fix makes the cli reactive to external recompiles instead.recursive(supported on Windows/macOS; degrades gracefully on Linux where the config/compiledevents still cover in-process changes).maincurrently failstsc -bdue to a missing export unrelated to this change); these two files are type-clean. Merge fix(preview): add missing fillIncludeModulesFromProjectConfig; add tsc type-check to PR CI #724 first, or together.Test