Skip to content

fix(vercel): resolve function runtime from package.json engines - #4768

Merged
pi0 merged 6 commits into
nitrojs:mainfrom
everton-dgn:feat/vercel-engines-runtime
Oct 17, 2026
Merged

pi0 merged 6 commits into
nitrojs:mainfrom
everton-dgn:feat/vercel-engines-runtime

Conversation

@everton-dgn

@everton-dgn everton-dgn commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Resolves #4767

❓ 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

Building with bun --bun wrote bun1.x to .vc-config.json even when package.json had engines.node, because the Vercel preset never read package.json.

The function runtime is now resolved in this order:

  1. vercel.functions.runtime in the Nitro config.
  2. engines in package.json. engines.node picks the newest supported Node.js major that intersects the range. engines.bun picks bun1.4.x when the range requires Bun 1.4, otherwise bun1.x. When both are set, Bun is only used if vercel.json also sets bunVersion.
  3. bunVersion in vercel.json.
  4. The runtime running the build (Bun, or the build's Node.js major).

Steps 2 and 3 match Vercel's getNodeVersion and getSupportedBunVersion in @vercel/build-utils (vercel/vercel#16685), including the warnings when engines.node wins over Bun. One difference: if engines.node matches no supported version, Nitro warns and falls back to step 4 instead of failing the build.

semver (already a devDependency) is bundled and only loaded through import() when it's needed (17 kB).

Behavior changes worth noting in the release notes:

  • Node.js 20 is removed from the supported list (Vercel discontinued it on 2026-10-01). Builds on Node 20 now emit nodejs22.x.
  • Projects with engines in package.json now get the runtime Vercel would pick from it, instead of the one from the build runtime.
  • An invalid or unsupported Bun range in engines.bun or bunVersion (e.g. 2.x, latest) now fails the build with an error naming the source, as Vercel does. Previously any bunVersion value produced bun1.x.

Docs (Vercel provider page) and the runtime JSDoc/type are updated. Unit tests in test/unit/vercel-runtime.test.ts cover the resolver and the build:before → .vc-config.json path, including the bun export condition.

📝 Checklist

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

🤖 Generated with AI assistant

Check engines in package.json before bunVersion in vercel.json and the
runtime running the build, with Vercel's precedence: engines.node or
engines.bun first, and bun only with bunVersion when both are set.
engines.node picks the newest supported Node.js version whose range
intersects it, and a range with no match warns and falls back to the
build's Node.js major.

Drop Node 20, which Vercel discontinued, from the supported versions
and the runtime type suggestions.

Bun builds now honor engines.node unless both engines and bunVersion
select Bun.
@everton-dgn
everton-dgn requested a review from pi0 as a code owner October 12, 2026 23:45
@vercel

vercel Bot commented Oct 12, 2026

Copy link
Copy Markdown

@everton-dgn 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 Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 65fedfce-fcb3-4235-9aaf-d72e37fcbf5c
📥 Commits

Reviewing files that changed from the base of the PR and between 8772bc4 and cda94a5.

📒 Files selected for processing: 4
  • docs/2.deploy/20.providers/vercel.md
  • src/presets/vercel/types.ts
  • src/presets/vercel/utils.ts
  • test/unit/vercel-runtime.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

Vercel runtime resolution now reads package.json engines and applies Node.js and Bun selection rules alongside explicit Nitro configuration, vercel.json, and the build runtime. Supported Node.js versions are 22 and 24. Tests and documentation cover runtime selection and generated function configuration.

Changes: Vercel Runtime Detection

Layer / File(s) Summary
Resolve runtime from configuration and engines
src/presets/vercel/types.ts, src/presets/vercel/utils.ts, docs/2.deploy/20.providers/vercel.md
Runtime resolution reads package.json engines and applies Node.js and Bun selection rules. Supported Node.js versions are 22 and 24. The type documentation and provider guide describe the runtime options, precedence, and fallback behavior.
Validate runtime selection and generated configuration
test/unit/vercel-runtime.test.ts
Unit tests cover explicit runtime precedence, Node.js and Bun engine-range selection, warnings and errors, and generated function runtimes and export conditions.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to cda94

The Vercel preset now picks its function runtime from package.json engines before falling back to the build runtime. No concrete problem was identified, and the change appears ready to merge after normal checks.

Security architecture risk: 🔵 Low · up to cda94

The change affects deployed runtime selection, not access permissions. Explicit runtime configuration still takes precedence, and the normal deploy command stops on build failure. Recovery behavior in external build and deployment integrations remains unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The effective scope is the functions generated by builds using the affected project configuration. The selected runtime enters the base function configuration and is inherited by custom functions unless overridden. The inspected flow does not introduce tenant, credential, IAM, or cross-project authority.

Trust Boundaries and Controls

  • observed — The new runtime-selection input is project package metadata read during the build, not request data. Explicit Nitro runtime configuration remains authoritative. Metadata-derived values pass through range-selection helpers before becoming runtime configuration; they are not used as executable source or shell commands in this flow.

Resilience and Maintainability Implications

  • inferred — Repeated resolution reuses the runtime stored on the Nitro instance, while function generation writes output sequentially without local transactional rollback. These behaviors predate the PR. Standard CLI cleanup and awaited deployment contain the new validation failure on the normal path; safe reuse after interruption or concurrent writes by external callers remains unverified rather than an established introduced vulnerability.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Issue #4767 requires Vercel runtime resolution to read package.json engines after explicit Nitro configuration. src/presets/vercel/utils.ts implements the required order, Node range intersection, …
Out of Scope Changes check Passed The changes stay within #4767. The resolver, tests, documentation, and runtime type updates support the Vercel runtime change. Removing Node 20 supports the issue's supported-version requirement. No u…
Title check Passed The title follows the Conventional Commits format with the type fix, scope vercel, and a concise description of the runtime resolution change.
Description check Passed The description directly explains the Vercel runtime resolution changes, affected behavior, documentation updates, tests, and validation steps.
Full details: Linked Issues check

Explanation

Issue #4767 requires Vercel runtime resolution to read package.json engines after explicit Nitro configuration. src/presets/vercel/utils.ts implements the required order, Node range intersection, Bun precedence, warnings, and build-runtime fallback. test/unit/vercel-runtime.test.ts covers resolution and generated .vc-config.json behavior. The documentation and runtime type updates describe the new behavior. Node 20 removal matches the supported-version update described in #4767.

Full details: Out of Scope Changes check

Explanation

The changes stay within #4767. The resolver, tests, documentation, and runtime type updates support the Vercel runtime change. Removing Node 20 supports the issue's supported-version requirement. No unrelated change is demonstrated.

Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@pi0x pi0x added the v3 label Oct 13, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 3dcdab8

@pi0x pi0x changed the title presets(vercel): resolve function runtime from package.json engines fix(vercel): resolve function runtime from package.json engines Oct 17, 2026
@pi0
pi0 merged commit 5994008 into nitrojs:main Oct 17, 2026
13 of 16 checks passed
@ali-vercel ali-vercel mentioned this pull request Oct 30, 2026
2 of 8 tasks
@pi0x pi0x removed the v3 label Nov 10, 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.

vercel: building with Bun publishes bun1.x even when package.json sets engines.node

3 participants