Skip to content

fix: vinext start for Cloudflare App Router worker exports#460

Open
JaredStowell wants to merge 1 commit intocloudflare:mainfrom
JaredStowell:jstowell/fix-vinext-start-worker-entry
Open

fix: vinext start for Cloudflare App Router worker exports#460
JaredStowell wants to merge 1 commit intocloudflare:mainfrom
JaredStowell:jstowell/fix-vinext-start-worker-entry

Conversation

@JaredStowell
Copy link
Contributor

Fix vinext start for App Router production builds emitted through @cloudflare/vite-plugin.
Reported here: #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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 11, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vinext@460

commit: 497e78a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant