Skip to content

fix(nitro): vercel function rules - preserve relative symlinks - #4490

Open
AndrewBarba wants to merge 1 commit into
nitrojs:mainfrom
AndrewBarba:barba/fix-vercel-function-symlinks
Open

fix(nitro): vercel function rules - preserve relative symlinks#4490
AndrewBarba wants to merge 1 commit into
nitrojs:mainfrom
AndrewBarba:barba/fix-vercel-function-symlinks

Conversation

@AndrewBarba

Copy link
Copy Markdown
Contributor

Summary

  • preserve relative symlink targets when Vercel functionRules copies the traced server function
  • add a regression using Nitro’s existing multi-version nf3 fixture

Context

nf3 emits relative links from package locations into node_modules/.nf3. Node’s fs.cp resolves those links by default, so copying __server.func into a route-specific function rewrites them to absolute paths in the temporary build directory. Once that directory is removed, the deployed function contains dangling dependency links.

Using verbatimSymlinks: true keeps the traced dependency graph self-contained in each copied function directory.

Related downstream report and workaround: vercel/eve#1279

Testing

  • regression confirmed failing before the fix and passing afterward
  • pnpm fmt
  • pnpm typecheck
  • pnpm vitest run test/presets/vercel.test.ts — 139 passed, 2 skipped, 2 todo
  • full suite attempted with TZ=UTC pnpm test; the Rollup run reached 1,025 passing tests and stopped on an unrelated Vite HMR assertion receiving two identical full-reload events instead of one

Signed-off-by: Andrew Barba <barba@hey.com>
@AndrewBarba
AndrewBarba requested a review from pi0 as a code owner July 28, 2026 16:50
@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 28, 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: d3ceb175-57dd-47de-a860-35f0908f6bf9

📥 Commits

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

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

📝 Walkthrough

Walkthrough

The Vercel preset now preserves symlink targets when copying custom function directories. The web preset test compares the nitro-lib symlink targets in generated server and route function directories.

Changes

Vercel symlink preservation

Layer / File(s) Summary
Preserve and verify dependency symlinks
src/presets/vercel/utils.ts, test/presets/vercel.test.ts
The function directory copy enables verbatimSymlinks, and the web preset test verifies matching nitro-lib symlink targets.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related issues

Possibly related PRs

  • nitrojs/nitro#4124: Both modify Vercel custom function directory generation.
  • nitrojs/nitro#4373: Both modify copy semantics in createFunctionDirWithCustomConfig, including symlink handling.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits and clearly describes the Vercel symlink preservation change.
Description check ✅ Passed The description is directly related to preserving Vercel function symlinks and the added regression test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: b90cd1b

@pi0
pi0 requested a review from RihanArfan July 28, 2026 17:22
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