Skip to content

presets(vercel): do not generate observability functions with fully prerendered routes - #4497

Merged
pi0 merged 1 commit into
mainfrom
fix/vercel-function-with-static
Aug 20, 2026
Merged

presets(vercel): do not generate observability functions with fully prerendered routes#4497
pi0 merged 1 commit into
mainfrom
fix/vercel-function-with-static

Conversation

@RihanArfan

Copy link
Copy Markdown
Member

🔗 Linked issue

Followup after #4412 is merged

❓ 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

Currently the Vercel preset creates a observability function for every route, including ones that are fully prerendered to a static file. The function takes presidence over the prerendered file with the Vercel build output so the prerendered route ends up getting SSR'd anyways.

This PR stops generating the observability route for routes that are prerendered, so they can be served.

📝 Checklist

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

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nitro.build Ready Ready Preview Aug 20, 2026 8:17pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fb6e3d66-dbe6-43a4-ada4-14a6f1b995cf

📥 Commits

Reviewing files that changed from the base of the PR and between df902d2 and d30e930.

📒 Files selected for processing (2)
  • src/presets/vercel/utils.ts
  • test/presets/vercel.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Vercel prerender handling now normalizes route overrides, preserves directory-index behavior, adds MIME types, and excludes prerendered paths from observability routes. Function directory copying preserves symlink targets. Tests cover routing, prerendering, generated artifacts, and symlinks.

Changes

Vercel prerender routing

Layer / File(s) Summary
Prerender override mapping
src/presets/vercel/utils.ts, test/presets/vercel.test.ts
Added getPrerenderOverrides for normalized prerender paths, directory-index handling, and MIME overrides. Updated Vercel route and function expectations.
Observability route filtering
src/presets/vercel/utils.ts, test/unit/vercel-observability-routes.test.ts
Exported getObservabilityRoutes and filtered routes that match prerendered files. Added coverage for compatibility dates, ordering, middleware, slash normalization, root routes, dynamic routes, and failed prerenders.
Function directory symlink preservation
src/presets/vercel/utils.ts, test/presets/vercel.test.ts
Enabled verbatimSymlinks during function directory copying and verified preserved dependency symlink targets.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to d30e9

This change prevents observability functions from overriding fully prerendered routes so those routes can remain static; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title uses the Conventional Commits structure type(scope): description and accurately describes the Vercel preset change.
Description check ✅ Passed The description clearly explains that prerendered Vercel routes must not generate observability functions.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/vercel-function-with-static

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.

@pkg-pr-new

pkg-pr-new Bot commented Jul 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4497

commit: df902d2

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/presets/vercel/utils.ts (1)

389-419: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Split the new prerender logic into an internal module.

src/presets/vercel/utils.ts now exceeds 570 lines. Move getPrerenderOverrides and the shared path normalization into a focused src/presets/vercel/_prerender.ts module. Import that module directly where needed.

As per coding guidelines, “Split logic across files; avoid long single-file modules (>200 LoC).”

Also applies to: 531-556

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/presets/vercel/utils.ts` around lines 389 - 419, Move
getPrerenderOverrides and its shared path-normalization symbols, including the
relevant slash and index matching constants, from utils.ts into a focused
internal _prerender.ts module. Export only the symbols needed by callers, then
update each usage to import them directly from _prerender.ts while preserving
the existing override behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/presets/vercel/utils.ts`:
- Around line 389-419: Move getPrerenderOverrides and its shared
path-normalization symbols, including the relevant slash and index matching
constants, from utils.ts into a focused internal _prerender.ts module. Export
only the symbols needed by callers, then update each usage to import them
directly from _prerender.ts while preserving the existing override behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 70d6a6c0-6f29-4292-92db-154a664b5960

📥 Commits

Reviewing files that changed from the base of the PR and between 77b77ff and df902d2.

📒 Files selected for processing (5)
  • src/presets/vercel/utils.ts
  • test/presets/fixtures/slash.ts
  • test/presets/vercel.test.ts
  • test/unit/vercel-observability-routes.test.ts
  • test/unit/vercel-overrides.test.ts

@pi0
pi0 marked this pull request as ready for review August 20, 2026 20:16
@pi0
pi0 self-requested a review as a code owner August 20, 2026 20:16
@pi0x
pi0x force-pushed the fix/vercel-function-with-static branch from df902d2 to d30e930 Compare August 20, 2026 20:16
@pi0 pi0 changed the title fix: do not generate observability functions with fully prerendered routes presets(vercel): do not generate observability functions with fully prerendered routes Aug 20, 2026
@pi0
pi0 merged commit 5cdece5 into main Aug 20, 2026
11 of 12 checks passed
@pi0
pi0 deleted the fix/vercel-function-with-static branch August 20, 2026 20:18
@pi0 pi0 mentioned this pull request Aug 21, 2026
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.

2 participants