Skip to content

fix(vercel): fix preview mode compat with srvx#4011

Merged
pi0 merged 1 commit intonitrojs:mainfrom
renantatsuo:fix/tanstack-prerender-vercel
Feb 10, 2026
Merged

fix(vercel): fix preview mode compat with srvx#4011
pi0 merged 1 commit intonitrojs:mainfrom
renantatsuo:fix/tanstack-prerender-vercel

Conversation

@renantatsuo
Copy link
Copy Markdown
Contributor

🔗 Linked issue

Resolves #3905

Also related: TanStack/router#6562

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

The Vercel preset was replacing the entire req.runtime object (req.runtime = { name: "vercel", vercel: { context } }), discarding req.runtime.node and causing a TypeError: Cannot destructure property 'req' of 'this.runtime.node' as it is undefined in srvx's Node adapter.

This fix uses ??= to match the same pattern used in the Netlify, Netlify Edge, and Cloudflare presets to set req.runtime and then sets req.runtime.vercel separately.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@renantatsuo renantatsuo requested a review from pi0 as a code owner February 9, 2026 17:55
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

The change modifies the Vercel runtime initialization in the web preset to conditionally initialize req.runtime only if undefined, while preserving existing req.runtime objects and ensuring Vercel context is set.

Changes

Cohort / File(s) Summary
Vercel Runtime Configuration
src/presets/vercel/runtime/vercel.web.ts
Changed runtime initialization from eager assignment to conditional logic that preserves existing req.runtime objects while ensuring Vercel context is set.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed Description is related to the changeset, explaining the bug being fixed and the solution approach matching the code changes.
Linked Issues check ✅ Passed PR addresses linked issue #3905 by preserving req.runtime object using ??= operator and setting req.runtime.vercel separately, matching the pattern used in other presets and resolving the TypeError.
Out of Scope Changes check ✅ Passed Changes are limited to fixing the Vercel preset runtime initialization and are directly scoped to resolving the linked issue; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title follows conventional commits format with 'fix' type and 'vercel' scope, accurately summarizing the main change of preserving req.runtime while setting vercel context.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 9, 2026

@renantatsuo is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@pi0 pi0 changed the title fix(vercel): fix vercel tanstack prerender fix(vercel): fix preview mode compat with srvx\ Feb 10, 2026
@pi0 pi0 changed the title fix(vercel): fix preview mode compat with srvx\ fix(vercel): fix preview mode compat with srvx Feb 10, 2026
Copy link
Copy Markdown
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ❤️

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nitrojs/nitro@4011

commit: 12ea10b

@pi0 pi0 merged commit 121495c into nitrojs:main Feb 10, 2026
10 of 11 checks passed
MickaelV0 added a commit to Roxabi/roxabi-talks that referenced this pull request Mar 27, 2026
Nitro 3.0.0's Vercel Web preset was missing the vite env bridge that
maps ssrRenderer to the TanStack Start SSR handler. Without it,
ssrRenderer called globalThis.fetch on the original request, which hit
the same Vercel function endpoint → INFINITE_LOOP_DETECTED (508).

The beta adds fetchViteEnv() + globalThis.__nitro_vite_envs__ to the
Vercel preset, routing SSR requests to ssr.mjs internally instead of
over HTTP. Also adapts vite.config.ts to the new plugin API (preset is
now a top-level property, not nested under config).

Refs: nitrojs/nitro#3905, nitrojs/nitro#4011, TanStack/router#6562

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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.

Tanstack Start prerender broken with Nitro v3 on Vercel

2 participants