[PR #460] [MERGED] fix: vinext start for Cloudflare App Router worker exports #587

Closed
opened 2026-05-06 13:08:55 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/460
Author: @JaredStowell
Created: 3/11/2026
Status: Merged
Merged: 3/11/2026
Merged by: @james-elicx

Base: mainHead: jstowell/fix-vinext-start-worker-entry


📝 Commits (1)

  • 189610f Add Node execution context handling

📊 Changes

2 files changed (+113 additions, -8 deletions)

View changed files

📝 packages/vinext/src/server/prod-server.ts (+40 -8)
📝 tests/app-router.test.ts (+73 -0)

📄 Description

Fix vinext start for App Router production builds emitted through @cloudflare/vite-plugin.
Reported here: https://github.com/cloudflare/vinext/issues/459

Cloudflare App Router builds can default-export a Worker-style object with fetch() instead of a plain request handler function. vinext start assumed the default export was always callable, which caused startup to fail with:

[vinext] RSC entry does not export a default handler function

This change teaches the production server to accept both supported App Router entry shapes:

  • default (request) => Response
  • default { fetch(request, env, ctx) }

It also keeps an explicit error for unsupported export shapes.

Changes

  • add App Router entry resolution in the prod server
  • support Worker-style default exports during vinext start
  • provide a minimal Node-side execution context so ctx.waitUntil() does not crash
  • add regression tests for:
    • Worker-style App Router default exports
    • clear failure on invalid export shapes

Verification

Ran:

  • pnpm test tests/app-router.test.ts
  • pnpm run fmt
  • pnpm run typecheck

Also verified manually with a real Cloudflare App Router build:

  • built examples/benchmarks
  • started it with node ../../packages/vinext/dist/cli.js start --port 4311
  • confirmed GET / returned 200 OK

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/460 **Author:** [@JaredStowell](https://github.com/JaredStowell) **Created:** 3/11/2026 **Status:** ✅ Merged **Merged:** 3/11/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `jstowell/fix-vinext-start-worker-entry` --- ### 📝 Commits (1) - [`189610f`](https://github.com/cloudflare/vinext/commit/189610f37281aafd2dbe844cc7eccf317e772aff) Add Node execution context handling ### 📊 Changes **2 files changed** (+113 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/prod-server.ts` (+40 -8) 📝 `tests/app-router.test.ts` (+73 -0) </details> ### 📄 Description Fix `vinext start` for App Router production builds emitted through `@cloudflare/vite-plugin`. Reported here: https://github.com/cloudflare/vinext/issues/459 Cloudflare App Router builds can default-export a Worker-style object with `fetch()` instead of a plain request handler function. `vinext start` assumed the default export was always callable, which caused startup to fail with: ```txt [vinext] RSC entry does not export a default handler function ``` This change teaches the production server to accept both supported App Router entry shapes: - `default (request) => Response` - `default { fetch(request, env, ctx) }` It also keeps an explicit error for unsupported export shapes. ## Changes - add App Router entry resolution in the prod server - support Worker-style default exports during `vinext start` - provide a minimal Node-side execution context so `ctx.waitUntil()` does not crash - add regression tests for: - Worker-style App Router default exports - clear failure on invalid export shapes ## Verification Ran: - `pnpm test tests/app-router.test.ts` - `pnpm run fmt` - `pnpm run typecheck` Also verified manually with a real Cloudflare App Router build: - built `examples/benchmarks` - started it with `node ../../packages/vinext/dist/cli.js start --port 4311` - confirmed `GET /` returned `200 OK` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:08:55 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#587
No description provided.