From 6b51f888a5836f54acd1edb08c95303216595e79 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa <4232207+hi-ogawa@users.noreply.github.com> Date: Fri, 31 Jul 2026 14:12:21 +0900 Subject: [PATCH 1/3] fix(rsc): fail fast when fixture server exits Document the full workspace build required by RSC examples. Co-authored-by: OpenCode --- packages/plugin-rsc/AGENTS.md | 19 +++++++++---- packages/plugin-rsc/CONTRIBUTING.md | 10 +++++-- packages/plugin-rsc/e2e/fixture.ts | 41 ++++++++++++++++++++++++----- 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/packages/plugin-rsc/AGENTS.md b/packages/plugin-rsc/AGENTS.md index db4b0097e..d2a5c4a77 100644 --- a/packages/plugin-rsc/AGENTS.md +++ b/packages/plugin-rsc/AGENTS.md @@ -11,12 +11,21 @@ Before creating or changing a conventional RSC example, use [`examples/starter-e ## Quick Reference for AI Agents -### Essential Commands +### Fresh Worktree Setup ```bash -# inside packages/plugin-rsc directory -pnpm build # build package +# from the repository root +pnpm install +pnpm build +``` + +Run the full workspace build before RSC E2E tests because examples may import other workspace packages, including `@vitejs/plugin-react`. + +### Package Commands + +```bash +# inside packages/plugin-rsc pnpm tsc # typecheck -pnpm test # Run unit tests -pnpm test-e2e # Run e2e tests +pnpm test --run # run unit tests +pnpm test-e2e # run E2E tests ``` diff --git a/packages/plugin-rsc/CONTRIBUTING.md b/packages/plugin-rsc/CONTRIBUTING.md index 3102292e6..24526f02d 100644 --- a/packages/plugin-rsc/CONTRIBUTING.md +++ b/packages/plugin-rsc/CONTRIBUTING.md @@ -40,9 +40,15 @@ Use colocated unit tests for self-contained transforms and utilities. ## Development Workflow +In a fresh worktree, install dependencies and build all workspace packages from the repository root before running E2E tests. RSC examples may import other workspace packages, including `@vitejs/plugin-react`, so building only `packages/plugin-rsc` is insufficient. + ```bash -# Build packages -pnpm dev # pnpm -C packages/plugin-rsc dev +# Install and build from the repository root +pnpm install +pnpm build + +# Watch the RSC package during development +pnpm -C packages/plugin-rsc dev # Type check pnpm -C packages/plugin-rsc tsc diff --git a/packages/plugin-rsc/e2e/fixture.ts b/packages/plugin-rsc/e2e/fixture.ts index e67650676..9e95cdb68 100644 --- a/packages/plugin-rsc/e2e/fixture.ts +++ b/packages/plugin-rsc/e2e/fixture.ts @@ -23,7 +23,7 @@ function runCli(options: { command: string; label?: string } & SpawnOptions) { console.log(styleText('magenta', label), data.toString()) }) const done = new Promise((resolve) => { - child.on('exit', (code) => { + child.on('close', (code) => { if (code !== 0 && code !== 143 && process.platform !== 'win32') { console.log(styleText('magenta', `${label}`), `exit code ${code}`) } @@ -32,15 +32,42 @@ function runCli(options: { command: string; label?: string } & SpawnOptions) { }) async function findPort(): Promise { - let stdout = '' - return new Promise((resolve) => { - child.stdout!.on('data', (data) => { - stdout += stripVTControlCharacters(String(data)) - const match = stdout.match(/http:\/\/localhost:(\d+)/) + let portOutput = '' + return new Promise((resolve, reject) => { + function cleanup() { + child.stdout!.off('data', onData) + child.off('close', onClose) + child.off('error', onError) + } + + function onData(data: Buffer) { + portOutput += stripVTControlCharacters(String(data)) + const match = portOutput.match(/http:\/\/localhost:(\d+)/) if (match) { + cleanup() resolve(Number(match[1])) } - }) + } + + function onClose(code: number | null, signal: NodeJS.Signals | null) { + cleanup() + const details = stderr.trim() || stdout.trim() + reject( + new Error( + `${label} exited with ${code ?? signal ?? 'unknown status'} before publishing a port` + + (details ? `\n${details}` : ''), + ), + ) + } + + function onError(error: Error) { + cleanup() + reject(error) + } + + child.stdout!.on('data', onData) + child.on('close', onClose) + child.on('error', onError) }) } From a3a8eb6436bff797016e1bcc145469220df72767 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 31 Jul 2026 15:02:08 +0900 Subject: [PATCH 2/3] nit --- packages/plugin-rsc/AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-rsc/AGENTS.md b/packages/plugin-rsc/AGENTS.md index d2a5c4a77..8da5507e1 100644 --- a/packages/plugin-rsc/AGENTS.md +++ b/packages/plugin-rsc/AGENTS.md @@ -19,7 +19,7 @@ pnpm install pnpm build ``` -Run the full workspace build before RSC E2E tests because examples may import other workspace packages, including `@vitejs/plugin-react`. +Run the full workspace build before RSC E2E tests because examples use other workspace packages, such as `@vitejs/plugin-react`. ### Package Commands From 11fc24415b3c8e6303fe0df8511571a969cdf59b Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 31 Jul 2026 15:02:16 +0900 Subject: [PATCH 3/3] nit --- packages/plugin-rsc/CONTRIBUTING.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/plugin-rsc/CONTRIBUTING.md b/packages/plugin-rsc/CONTRIBUTING.md index 24526f02d..b16ab9d89 100644 --- a/packages/plugin-rsc/CONTRIBUTING.md +++ b/packages/plugin-rsc/CONTRIBUTING.md @@ -40,8 +40,6 @@ Use colocated unit tests for self-contained transforms and utilities. ## Development Workflow -In a fresh worktree, install dependencies and build all workspace packages from the repository root before running E2E tests. RSC examples may import other workspace packages, including `@vitejs/plugin-react`, so building only `packages/plugin-rsc` is insufficient. - ```bash # Install and build from the repository root pnpm install