Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vercel): auto-detect runtime version #879

Merged
merged 3 commits into from
Feb 8, 2023

Conversation

smaeda-ks
Copy link
Contributor

@smaeda-ks smaeda-ks commented Jan 25, 2023

Currently, it's setting nodejs16.x statically, so any serverless functions are deployed with Node.js v16.x regardless of the project's Node version setting:
https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/node-js#node.js-version

This PR changes the behavior and starts producing the .vc-config.json file (for Vercel Build Output API) with the running OS's Node runtime version. This prevents Node version mismatch between build time and runtime.

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 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)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

📝 Checklist

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

@smaeda-ks smaeda-ks changed the title [vercel] auto-detect runtime version feat(vercel): auto-detect runtime version Jan 25, 2023
src/types/presets.ts Outdated Show resolved Hide resolved
src/presets/vercel.ts Outdated Show resolved Hide resolved
@bastian-friedrich
Copy link

@smaeda-ks any news on this PR? We really need this in a prod env.

@pi0
Copy link
Member

pi0 commented Jan 31, 2023

@smaeda-ks Can we split auto detection part to merge new configuration sooner? 🙏🏼

kodiakhq bot pushed a commit to vercel/vercel that referenced this pull request Jan 31, 2023
This PR adds a few new environment variables for project settings.

This allows frameworks targeting the [Build Output API](https://vercel.com/docs/build-output-api/v3) to read data that is normally only available in through the `config` object when developing a [Builder/Runtime](https://github.com/vercel/vercel/blob/main/DEVELOPING_A_RUNTIME.md).

This will also solve the problem of old Builders/Runtimes that never passed the `config` through to `getNodeVersion()`.

- Related to nitrojs/nitro#879
@smaeda-ks smaeda-ks requested review from styfle and pi0 and removed request for pi0 and styfle February 2, 2023 06:13
@smaeda-ks
Copy link
Contributor Author

@pi0 @styfle Could you please review this updated version? Thanks!

src/presets/vercel.ts Outdated Show resolved Hide resolved
src/presets/vercel.ts Outdated Show resolved Hide resolved
@pi0
Copy link
Member

pi0 commented Feb 8, 2023

Hi! Is there any updates on this? Today we are going to release Nitropack 2.1 / Nuxt 3.2

@styfle
Copy link

styfle commented Feb 8, 2023

Do we have example code that reproduces this issue? How can we confirm this PR fixes the issue?

Copy link
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.

I trust process.versions.node.split('.')[0] is expected behavior from vercel.. @styfle do you confirm too?

@codecov
Copy link

codecov bot commented Feb 8, 2023

Codecov Report

Merging #879 (412b8f1) into main (860aa76) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #879      +/-   ##
==========================================
+ Coverage   67.79%   67.81%   +0.01%     
==========================================
  Files          59       59              
  Lines        6003     6005       +2     
  Branches      679      679              
==========================================
+ Hits         4070     4072       +2     
  Misses       1924     1924              
  Partials        9        9              
Impacted Files Coverage Δ
src/presets/vercel.ts 76.52% <100.00%> (+0.20%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link

@styfle styfle left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

Lets try it out with a real deployment and try setting engines to see if that is respected.

@smaeda-ks
Copy link
Contributor Author

smaeda-ks commented Feb 8, 2023

Tested that the PR works as expected: smaeda-ks/nuxt3-vercel-nitropack-pr-879#1

preview: https://nuxt3-vercel-nitropack-pr-879-git-test-smaeda-ks.vercel.app/api/hello

build logs: https://vercel.com/smaeda-ks/nuxt3-vercel-nitropack-pr-879/7DqeaQXiJ6YsdwurX4oqWuzTPvrf#L6

@pi0 pi0 merged commit becd3b7 into nitrojs:main Feb 8, 2023
@bastian-friedrich
Copy link

Awesome! It works! :) Thank you guys so much!

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.

4 participants