문제
깨끗한 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
41 lines
1.8 KiB
TypeScript
41 lines
1.8 KiB
TypeScript
import { execFileSync } from "node:child_process";
|
|
import path from "node:path";
|
|
|
|
import type { Plugin } from "vite";
|
|
|
|
/**
|
|
* 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
|
|
* 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 {
|
|
name: "frontend-dev-release-manifest",
|
|
// Vitest also starts Vite in serve mode; tests never fetch the manifest
|
|
// from a server, so they skip the child process.
|
|
apply: (_config, env) => env.command === "serve" && !process.env["VITEST"],
|
|
configureServer(server) {
|
|
const manifest = execFileSync(
|
|
process.execPath,
|
|
[path.join(repositoryRoot, "scripts/write-dev-release-manifest.ts")],
|
|
{ cwd: repositoryRoot, encoding: "utf8", stdio: ["ignore", "pipe", "inherit"] },
|
|
);
|
|
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")) {
|
|
next();
|
|
return;
|
|
}
|
|
response.setHeader("content-type", "application/json");
|
|
response.setHeader("cache-control", "no-store");
|
|
response.end(manifest);
|
|
});
|
|
},
|
|
};
|
|
}
|