mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #273] [MERGED] fix(config): pass correct Next.js phase to function-form configs + instrumentation test coverage #431
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#431
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/273
Author: @NathanDrake2406
Created: 3/5/2026
Status: ✅ Merged
Merged: 3/6/2026
Merged by: @james-elicx
Base:
main← Head:fix/config-phase-instrumentation-tests📝 Commits (8)
9aa9182fix(config): pass correct Next.js phase to function-form configs18755cdtest: add instrumentation module test coverage1da418efix(test): use shared helper for App Router static export testf6f23daMerge remote-tracking branch 'upstream/main' into fix/config-phase-instrumentation-testsd9632f1fix: address PR review feedback502ea91refactor: use phase constants in tests, simplify pure function test setupe365024refactor: use shared startFixtureServer helper in static export testsa7af79cmerge: resolve conflict with upstream/main📊 Changes
5 files changed (+243 additions, -25 deletions)
View changed files
📝
packages/vinext/src/config/next-config.ts(+6 -5)📝
packages/vinext/src/index.ts(+3 -1)➕
tests/instrumentation.test.ts(+176 -0)➕
tests/next-config.test.ts(+53 -0)📝
tests/static-export.test.ts(+5 -19)📄 Description
Summary
fix(config):
unwrapConfig()hardcoded"phase-development-server"when calling function-form Next.js configs, even during production builds. Apps that branch onphaseinnext.config.ts(e.g.(phase) => phase === "phase-production-build" ? prodConfig : devConfig) received the wrong config duringvinext build. Now maps Vite'senv.commandto the correct Next.js phase ("build"→"phase-production-build","serve"→"phase-development-server").test(instrumentation): Added 11 tests for
server/instrumentation.tswhich previously had zero coverage. CoversfindInstrumentationFile(file discovery priority, src/ fallback, null when absent),runInstrumentation(register lifecycle, onRequestError storage, error isolation), andreportRequestError(handler forwarding, no-op without handler, handler error isolation).fix(test): Fixed 6 pre-existing failures in
static-export.test.tsApp Router section. The test used a localstartFixtureServerthat loaded the fixture'svite.config.tsviaconfigFile, which caused RSC plugin timing issues on Node 25. Switched to the sharedstartFixtureServerHelperfromhelpers.ts(usesconfigFile: falsewith explicit plugins), matching the pattern used byapp-router.test.ts.Test plan
npx vitest run tests/next-config.test.ts— 3 tests verifying phase propagation (production build phase, dev default, object-form ignores phase)npx vitest run tests/instrumentation.test.ts— 11 tests covering file discovery, register/onRequestError lifecycle, error isolationnpx vitest run tests/static-export.test.ts— 14 tests now all pass (was 6 failures)npx vitest run— full suite passes (2182 passed, 0 failed)pnpm run typecheck— clean🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.