Skip to content

fix: do not generate observability functions with fully prerendered routes - #4497

Draft
RihanArfan wants to merge 6 commits into
mainfrom
fix/vercel-function-with-static
Draft

fix: do not generate observability functions with fully prerendered routes#4497
RihanArfan wants to merge 6 commits 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 Jul 30, 2026 12:04pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f841fc0-b816-43ba-8618-4c1d63829ad7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

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

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