From 0eba0821bdf1478ece27e0ecba4078b776fc7fa9 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 5 Nov 2026 03:12:27 +0900 Subject: [PATCH] =?UTF-8?q?fix(dev):=20dev=20release=20manifest=EB=A5=BC?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=EB=A1=9C=20=EC=93=B0=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EA=B3=A0=20=EB=A9=94=EB=AA=A8=EB=A6=AC=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=82=B8=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제 깨끗한 clone의 FE-GATE-008에서 dev server를 쓰는 capability e2e가 "requestfailed:GET:/release-manifest.json:net::ERR_ABORTED"로 1~4건씩 떨어졌다(세 번 중 세 번, 부하 9~30). 플러그인(db5728b)이 dev server 시작 때 .generated/frontend-runtime/에 manifest를 쓰는데, polling 감시 (CHOKIDAR_USEPOLLING=1)가 그 새 파일을 서버가 뜬 뒤에 보고 부팅 중인 페이지를 다시 불러오면 진행 중인 manifest 요청이 끊긴다고 본다. 플러그인을 넣기 전 같은 부하의 회차들은 66건 모두 통과했다. 고른 방법 - 자식 프로세스가 manifest를 stdout으로 내고, 플러그인은 그 문자열을 메모리에 두고 낸다. 파일을 쓰지 않으므로 감시가 볼 것이 없다. devReleaseManifest(source)가 문자열을 돌려준다. 위험·한계 - 원인을 감시 이벤트로 직접 관측하지는 않았다(추론). 수정 뒤 재실행으로 확인한다. 검증 - tests/unit/dev-release-manifest.test.ts 2건, check:types, lint 통과. Refs: docs/reviews/2026-11-03-maturity-review/README.md 14.5 X4 --- scripts/lib/dev-release-manifest.ts | 22 +++++++--------------- scripts/write-dev-release-manifest.ts | 19 ++++++++----------- tests/unit/dev-release-manifest.test.ts | 14 +++----------- 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/scripts/lib/dev-release-manifest.ts b/scripts/lib/dev-release-manifest.ts index 0395cd6a..d9acd8cf 100644 --- a/scripts/lib/dev-release-manifest.ts +++ b/scripts/lib/dev-release-manifest.ts @@ -1,24 +1,17 @@ import { execFileSync } from "node:child_process"; -import { readFileSync } from "node:fs"; import path from "node:path"; import type { Plugin } from "vite"; -/** - * Generated at dev server start, beside the build's generated contract set and - * ignored with it. Not under src/: the removal drills scan src/ for the - * sample's names, and this copies the placeholder's route chunks. - */ -export const DEV_RELEASE_MANIFEST_PATH = ".generated/frontend-runtime/dev-release-manifest.json"; - /** * Serve only. The dev server answers the runtime's release-manifest request * with scripts/write-dev-release-manifest.ts's output instead of the committed * placeholder, so a feature that `create:feature` just added boots in * `corepack pnpm dev` and in the dev-server browser tests. The manifest is - * written in a child process because it imports the installed feature - * declarations, which this config must not load. A build never uses it: the - * built manifest comes from scripts/generate-build-manifest.ts. + * built once in a child process at server start, because it imports the + * installed feature declarations, which this config must not load, and kept + * in memory: no file is written for the server's watcher to see. A build never + * uses it: the built manifest comes from scripts/generate-build-manifest.ts. */ export function devReleaseManifestPlugin(repositoryRoot = process.cwd()): Plugin { return { @@ -27,12 +20,11 @@ export function devReleaseManifestPlugin(repositoryRoot = process.cwd()): Plugin // from a server, so they skip the child process. apply: (_config, env) => env.command === "serve" && !process.env["VITEST"], configureServer(server) { - execFileSync( + const manifest = execFileSync( process.execPath, [path.join(repositoryRoot, "scripts/write-dev-release-manifest.ts")], - { cwd: repositoryRoot, stdio: "inherit" }, + { cwd: repositoryRoot, encoding: "utf8", stdio: ["ignore", "pipe", "inherit"] }, ); - const manifest = path.join(repositoryRoot, DEV_RELEASE_MANIFEST_PATH); server.middlewares.use((request, response, next) => { const pathname = new URL(request.url ?? "/", "http://dev.invalid").pathname; if (request.method !== "GET" || !pathname.endsWith("/release-manifest.json")) { @@ -41,7 +33,7 @@ export function devReleaseManifestPlugin(repositoryRoot = process.cwd()): Plugin } response.setHeader("content-type", "application/json"); response.setHeader("cache-control", "no-store"); - response.end(readFileSync(manifest)); + response.end(manifest); }); }, }; diff --git a/scripts/write-dev-release-manifest.ts b/scripts/write-dev-release-manifest.ts index 48a6c75a..a96e28da 100644 --- a/scripts/write-dev-release-manifest.ts +++ b/scripts/write-dev-release-manifest.ts @@ -1,27 +1,24 @@ -import { mkdir, readFile, writeFile } from "node:fs/promises"; -import { dirname } from "node:path"; +import { readFile } from "node:fs/promises"; import { buildContractSet } from "./generate-contract-set.ts"; -import { DEV_RELEASE_MANIFEST_PATH } from "./lib/dev-release-manifest.ts"; /** * The release manifest the dev server serves: the committed placeholder * (public/release-manifest.json) with the contract set of the features * installed now. Boot checks that set against the installed declarations, so * a placeholder with a fixed set refused every app with one more feature - * (CONTRACT_SET_PACKAGE_MISSING) until someone edited it by hand. The output - * is generated and ignored, as .generated/ is. + * (CONTRACT_SET_PACKAGE_MISSING) until someone edited it by hand. */ -export async function writeDevReleaseManifest( +export async function devReleaseManifest( source = "public/release-manifest.json", - output = DEV_RELEASE_MANIFEST_PATH, -): Promise { +): Promise { const manifest = JSON.parse(await readFile(source, "utf8")) as Record; manifest["contractSet"] = buildContractSet(); - await mkdir(dirname(output), { recursive: true }); - await writeFile(output, `${JSON.stringify(manifest, null, 2)}\n`, "utf8"); + return `${JSON.stringify(manifest, null, 2)}\n`; } +// Printed, not written: a file the dev server's watcher picks up after the +// server started could reload a page while it is booting. if (process.argv[1]?.endsWith("write-dev-release-manifest.ts")) { - await writeDevReleaseManifest(); + process.stdout.write(await devReleaseManifest()); } diff --git a/tests/unit/dev-release-manifest.test.ts b/tests/unit/dev-release-manifest.test.ts index 9eaee1d9..a0b72ff6 100644 --- a/tests/unit/dev-release-manifest.test.ts +++ b/tests/unit/dev-release-manifest.test.ts @@ -5,7 +5,7 @@ import path from "node:path"; import { afterEach, describe, expect, it } from "vitest"; import { buildContractSet } from "../../scripts/generate-contract-set.ts"; -import { writeDevReleaseManifest } from "../../scripts/write-dev-release-manifest.ts"; +import { devReleaseManifest } from "../../scripts/write-dev-release-manifest.ts"; /** * 1103 X2. `create:feature` declares a contract package; the dev server used @@ -22,7 +22,6 @@ describe("dev release manifest", () => { it("serves the placeholder with the contract set of the installed features", async () => { directory = await mkdtemp(path.join(tmpdir(), "dev-release-manifest-")); const source = path.join(directory, "release-manifest.json"); - const output = path.join(directory, "generated", "dev-release-manifest.json"); await writeFile( source, JSON.stringify({ @@ -36,22 +35,15 @@ describe("dev release manifest", () => { }), ); - await writeDevReleaseManifest(source, output); - - const written = JSON.parse(await readFile(output, "utf8")) as Record; + const written = JSON.parse(await devReleaseManifest(source)) as Record; expect(written["buildId"]).toBe("local-build"); expect(written["contractSet"]).toEqual(JSON.parse(JSON.stringify(buildContractSet()))); }); it("keeps every other field of the committed placeholder", async () => { - directory = await mkdtemp(path.join(tmpdir(), "dev-release-manifest-")); - const output = path.join(directory, "dev-release-manifest.json"); - - await writeDevReleaseManifest("public/release-manifest.json", output); - // Whatever features are installed (a product's, or a drill's generated // one): only the contract set may differ from the placeholder. - const { contractSet, ...written } = JSON.parse(await readFile(output, "utf8")) as Record< + const { contractSet, ...written } = JSON.parse(await devReleaseManifest()) as Record< string, unknown >;