fix(service-worker): build the worker from the profile config (06-10)

The worker build read public/config.json, the local profile, even in a
production build (F-8). It now reads dist/config.json and fails when that
document's APP_ENV is not the build's APP_PROFILE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
donghyeon-ka
2026-09-27 12:57:41 +09:00
co-authored by Claude Opus 5.5
parent dd7a44677b
commit cefb0b2975
4 changed files with 59 additions and 10 deletions
+3 -1
View File
@@ -32,7 +32,9 @@ import { SELF_UNREGISTERING_SERVICE_WORKER } from "./lib/self-unregistering-serv
* without it every build — including a production one — ships the local
* runtime document. The Service Worker asset scan excludes `config.json`
* (`scripts/generate-service-worker-assets.ts`), so the order against step 5
* is not what keeps the profile out of the worker cache (13-15).
* is not what keeps the profile out of the worker cache (13-15). Step 6 reads
* the release manifest URL from the `dist/config.json` step 4 wrote, and fails
* if its `APP_ENV` is not `APP_PROFILE` (06-10).
*/
const selection = INSTALLED_RUNTIME_CAPABILITIES.serviceWorker;
+11 -1
View File
@@ -29,7 +29,10 @@ export function resolveServiceWorkerBuildInput(input: Readonly<{
selection: InstalledServiceWorkerSelection | null;
assets: unknown;
contractSet: unknown;
/** `dist/config.json`, materialized from the build's profile (06-10). */
runtimeConfig: unknown;
/** The build's `APP_PROFILE`; the runtime document must be for it. */
appProfile: string;
buildId: string;
releaseId: string;
}>): ServiceWorkerBuildInput {
@@ -70,7 +73,14 @@ export function resolveServiceWorkerBuildInput(input: Readonly<{
throw new TypeError("Generated contract set digest is invalid.");
}
const runtimeConfig = record(input.runtimeConfig);
const releaseManifestUrl = runtimeConfig?.RELEASE_MANIFEST_URL;
// 06-10 / F-8. `public/config.json` is the local profile; a worker built from
// it for another profile would carry that profile's URLs.
if (runtimeConfig?.APP_ENV !== input.appProfile) {
throw new TypeError(
`Service Worker runtime config APP_ENV ${String(runtimeConfig?.APP_ENV)} does not match APP_PROFILE ${input.appProfile}.`,
);
}
const releaseManifestUrl = runtimeConfig.RELEASE_MANIFEST_URL;
if (
typeof releaseManifestUrl !== "string" ||
releaseManifestUrl.length === 0 ||