mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #289] [MERGED] fix(instrumentation): defer ssrLoadModule to post-middleware hook #448
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#448
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/289
Author: @Divkix
Created: 3/6/2026
Status: ✅ Merged
Merged: 3/7/2026
Merged by: @southpolesteve
Base:
main← Head:fix/instrumentation-crash-167📝 Commits (4)
31791befix(instrumentation): defer ssrLoadModule call to post-middleware hook7e56c5ffix(instrumentation): address review comments on deferred ssrLoadModule2fd3ed5test: address instrumentation review feedback27765dbMerge branch 'cloudflare:main' into fix/instrumentation-crash-167📊 Changes
2 files changed (+32 additions, -7 deletions)
View changed files
📝
packages/vinext/src/index.ts(+9 -7)📝
tests/features.test.ts(+23 -0)📄 Description
Summary
vite devcrashes immediately when a project hasinstrumentation.tsrunInstrumentation()call from theconfigureServerbody into the returned post-middleware function, where Vite's SSR environment transport channel is fully initializedregister()invocationRoot Cause
Vite 7's
SSRCompatModuleRunnerrequires the SSR environment's transport channel beforessrLoadModule()can be called. DuringconfigureServer(), the channel isn't ready yet →TypeError: Cannot read properties of undefined (reading 'outsideEmitter').Changes
packages/vinext/src/index.tsrunInstrumentationfrom configureServer body into returned post-middleware functiontests/features.test.tsTest plan
pnpm test— all 2204 tests pass (2 pre-existing failures in static-export/ecosystem unrelated to this change)pnpm run typecheck— no new type errorspnpm run test:e2e— no regressionsinstrumentation.ts, runvite dev, confirm no crash/bonk
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.