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(core): fix postinstall failure due to project graph build error #9960

Merged

Conversation

tommazzo89
Copy link
Contributor

Current Behavior

The postinstall hook of the nx package fails if a project.json file is missing. This can happen, e.g., during a Docker build, when the layer used for npm install/npm ci only contains the workspace definition files (workspace.json, package.json, etc.) to enable caching of this step (see this comment for details).

Expected Behavior

The postinstall step no longer fails, because buildProjectGraphWithoutDaemon() no longer exits the process with an error code (process.exit(1)) and, thus, allows the init script to catch the error.

@ Nx maintainers: I don't know why the process.exit(1) call was introduced in the first place. Thus, I don't know if removing it has any undesired side effects. In case there are any, please inform me what needs to be fixed.

Related Issue(s)

Fixes #9451

@nx-cloud
Copy link

nx-cloud bot commented Apr 22, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 2d35a2c. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 12 targets

Sent with 💌 from NxCloud.

@vercel
Copy link

vercel bot commented Apr 22, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
nx-dev ⬜️ Ignored (Inspect) Apr 23, 2022 at 1:42PM (UTC)

@tommazzo89 tommazzo89 closed this Apr 22, 2022
@tommazzo89 tommazzo89 reopened this Apr 22, 2022
@tommazzo89
Copy link
Contributor Author

Hi guys,

How can I rerun the checks? According to the logs they failed due to a timeout: Error when connecting to Nx Cloud. Code: ECONNABORTED. Error: timeout of 10000ms exceeded.

Delegate error handling to calling functions and avoid `process.exit(1)`, which causes the package's postinstall stage to fail if there are problems with the project graph

Closes nrwl#9451
@tommazzo89 tommazzo89 force-pushed the fix/project-graph-postinstall-failure branch from 6bb1608 to 2d35a2c Compare April 23, 2022 13:39
Copy link
Collaborator

@FrozenPandaz FrozenPandaz left a comment

Choose a reason for hiding this comment

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

This looks good to me. This was added here a long time ago when we didn't have a clean way to handle error messages. Throwing the error instead of exiting the process should do no further harm.

Thank you for your contribution. LGTM 🎉

@FrozenPandaz FrozenPandaz merged commit 2647e48 into nrwl:master Apr 25, 2022
@tommazzo89
Copy link
Contributor Author

Great, thanks a lot @FrozenPandaz!

@tommazzo89 tommazzo89 deleted the fix/project-graph-postinstall-failure branch April 26, 2022 08:04
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants