fix(serve): hard-fail when build is stale vs current config#252
Open
sauravvarma wants to merge 1 commit into
Open
fix(serve): hard-fail when build is stale vs current config#252sauravvarma wants to merge 1 commit into
sauravvarma wants to merge 1 commit into
Conversation
PUBLIC_STATIC_ASSET_URL and PUBLIC_STATIC_ASSET_PATH are baked into the client bundle at build time via webpack DefinePlugin and publicPath. When config/config.json changes between build and serve (common when local IP changes), `catalyst serve` keeps serving the old build: the boot log prints the new host, but the HTML still references chunks at the old host. The device fails to load assets with no obvious signal from serve. - build.js writes BUILD_OUTPUT_PATH/build-meta.json with the values that webpack embedded. - serve.js compares build-meta.json against current config.json on startup and exits with a clear diff message on mismatch. Missing build-meta.json (older builds) warns and proceeds. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
DeputyDev will no longer review pull requests automatically.To request a review, simply comment #review on your pull request—this will trigger an on-demand review whenever you need it. |
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.
Summary
PUBLIC_STATIC_ASSET_URLandPUBLIC_STATIC_ASSET_PATHinBUILD_OUTPUT_PATH/build-meta.jsonat build time (the values webpack embeds into the client bundle viapublicPath+DefinePlugin).catalyst servestartup, compares the embedded values against the currentconfig/config.jsonand exits with a clear diff message on mismatch.build-meta.json(older builds) emits a warning and proceeds — no break for existing deployments.Closes #251.
Why
catalyst servecurrently re-readsconfig.jsonfor the boot log andNODE_SERVER_HOSTNAME/PORT, but the asset host that ends up in the served HTML was frozen at build time. When config changes between build and serve (common when local IP changes), serve logsLocal: http://<new-host>while the HTML still references chunks at the old host. On a device this looks like "page loads, no JS/CSS" with no signal from the serve process.Behavior
Before (config changed from
AtoBafter the build, thennpm run serve):…and the HTML embeds
http://A:3005/assets/runtime.*.js. Silent stale serve.After:
Exit code 1.
Test plan
npm run buildin a fixture app writesbuild/build-meta.jsonwith currentPUBLIC_STATIC_ASSET_URL/PUBLIC_STATIC_ASSET_PATH.npm run servewith matching config starts normally.PUBLIC_STATIC_ASSET_URLinconfig/config.jsonand re-runnpm run serve— exits non-zero with the diff message above, no server process spawned.build/build-meta.jsonand re-runnpm run serve— emits the "skipping check" warning and proceeds (backwards-compat with builds from prior versions).Notes / open questions
--allow-stale-buildflag if maintainers prefer.PUBLIC_STATIC_ASSET_*keys are tracked.CLIENT_ENV_VARIABLESvalues are also embedded viaDefinePlugin; extending the check to those is a small follow-up if desired.🤖 Generated with Claude Code