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

fix: node18 support for netlify/build #4726

Merged
merged 4 commits into from
Nov 29, 2022

Conversation

lukasholzer
Copy link
Contributor

@lukasholzer lukasholzer commented Nov 28, 2022

🎉 Thanks for submitting a pull request! 🎉

Summary

Fixes https://github.com/netlify/pillar-workflow/issues/624

Running on Node 16.x netlify-build --nodePath /Users/lukasholzer/.nvm/versions/node/v18.11.0/bin/node is working now with this change on a next.js site.

This basically reverts ded368d#diff-aadec7c55ab8f716f3c2d33ec17ce26331572cf6f1eada1bc9274b4363ebbc80

IMHO a IPC communication always needs to be serialisable as JSON otherwise we will always run in problems with different node major versions.

I'm currently testing if something is not serialisable inside the errors but until now I could. not find any issue (as mikael pointed out back in the commit that introduced the advanced serialization). as we still to the error to json conversion: https://github.com/netlify/build/blob/main/packages/build/src/error/build.js#L8-L17


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures
    we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
    something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)
image

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2022

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

@lukasholzer lukasholzer marked this pull request as ready for review November 28, 2022 09:16
@@ -37,15 +37,14 @@ const tStartPlugins = async function ({ pluginsOptions, buildDir, childEnv, logs
export const startPlugins = measureDuration(tStartPlugins, 'start_plugins')

const startPlugin = async function ({ pluginDir, nodePath, buildDir, childEnv }) {
const childProcess = execaNode(CHILD_MAIN_FILE, {
const childProcess = execaNode(CHILD_MAIN_FILE, [], {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This are the types of execaNode seems like we where using it wrongly:

2nd argument here are the arguments passed down to the child process

CleanShot 2022-11-28 at 10 30 19

@@ -2788,14 +2788,10 @@ Generated by [AVA](https://avajs.dev).
CACHE_DIR: '.netlify/cache',␊
IS_LOCAL: true,␊
NETLIFY_BUILD_VERSION: '1.0.0',␊
SITE_ID: undefined,␊
Copy link
Contributor Author

Choose a reason for hiding this comment

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

JSON serialisation contains undefined values in comparison of v8.serialise. which should not make any difference just the snapshot looks differently.

Copy link
Member

Choose a reason for hiding this comment

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

I think you mean the other way around, i.e. JSON serialisation omits undefined values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep :D

@danez
Copy link
Contributor

danez commented Nov 28, 2022

Reading about this seems that the serialization is backwards compatible (node 18 can deserialize data from older node versions) but not forward compatible (older node cannot deserialize data from node 18)
nodejs/node#42192
That also means this can happen with every major node version, and I would say as long as we use ipc we should not enable this at all.

Copy link
Contributor

@danez danez left a comment

Choose a reason for hiding this comment

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

Not sure why it was enabled, but it looks like as we convert everything to json we should be fine.

Copy link
Member

@eduardoboucas eduardoboucas left a comment

Choose a reason for hiding this comment

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

I also can't see an issue with this change, but I'd recommend a very slow rollout just in case.

@@ -2788,14 +2788,10 @@ Generated by [AVA](https://avajs.dev).
CACHE_DIR: '.netlify/cache',␊
IS_LOCAL: true,␊
NETLIFY_BUILD_VERSION: '1.0.0',␊
SITE_ID: undefined,␊
Copy link
Member

Choose a reason for hiding this comment

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

I think you mean the other way around, i.e. JSON serialisation omits undefined values?

@lukasholzer
Copy link
Contributor Author

I'm not planning to roll this out in our low risk week but after it I would do a soft roll out via canary?

@eduardoboucas
Copy link
Member

Sounds good! 🚀

@lukasholzer lukasholzer merged commit 28347ca into main Nov 29, 2022
@lukasholzer lukasholzer deleted the fix/node-18-support-for-netlify-build branch November 29, 2022 10:00
This was referenced Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants