Skip to content

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

Merged
pi0 merged 3 commits into
nitrojs:mainfrom
smaeda-ks:vercel-node-runtime
Feb 8, 2023
Merged

pi0 merged 3 commits into
nitrojs:mainfrom
smaeda-ks:vercel-node-runtime

Conversation

@smaeda-ks

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

Copy link
Copy Markdown
Contributor

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 force-pushed the vercel-node-runtime branch from 436eeb1 to 5c6c601 Compare January 25, 2023 15:27
@smaeda-ks smaeda-ks changed the title [vercel] auto-detect runtime version feat(vercel): auto-detect runtime version Jan 25, 2023
Comment thread src/types/presets.ts Resolved
Comment thread src/presets/vercel.ts Resolved
@bastian-friedrich

Copy link
Copy Markdown

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

@pi0

pi0 commented Jan 31, 2023

Copy link
Copy Markdown
Member

@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 force-pushed the vercel-node-runtime branch from 49d2c3c to 5df76ca Compare February 2, 2023 06:08
@smaeda-ks
smaeda-ks force-pushed the vercel-node-runtime branch from 5df76ca to 9eb9e29 Compare February 2, 2023 06:12
@smaeda-ks
smaeda-ks requested review from pi0 and styfle and removed request for pi0 and styfle February 2, 2023 06:13
@smaeda-ks

Copy link
Copy Markdown
Contributor Author

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

Comment thread src/presets/vercel.ts Resolved
Comment thread src/presets/vercel.ts Resolved
Comment thread src/presets/vercel.ts Resolved
@pi0

pi0 commented Feb 8, 2023

Copy link
Copy Markdown
Member

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

@styfle

styfle commented Feb 8, 2023

Copy link
Copy Markdown
Member

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

@pi0 pi0 left a comment •

Copy link
Copy Markdown
Member

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

codecov Bot commented Feb 8, 2023 •

Copy link
Copy Markdown

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.

@styfle styfle left a comment

Copy link
Copy Markdown
Member

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

smaeda-ks commented Feb 8, 2023 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown

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

This branch was successfully deployed

1 active deployment
Preview — 412b8f19 Deployed Feb 8, 2023 by vercel[bot]
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