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

Nx operations hangs indefinitely #27494

Open
1 of 4 tasks
JbIPS opened this issue Aug 17, 2024 · 64 comments
Open
1 of 4 tasks

Nx operations hangs indefinitely #27494

JbIPS opened this issue Aug 17, 2024 · 64 comments
Assignees

Comments

@JbIPS
Copy link

JbIPS commented Aug 17, 2024

Current Behavior

I'm trying to add Nx to my TS monorepo.

On first try, I installed it (pnpm i nx) but any run would hang on indefinitely. So I removed it, tried to reinstall it but now it hangs at postinstall

node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx: Running postinstall script

I tried other approach like pnpm dlx nx@latest init or even npx nx@latest init but it hangs at

 NX   🧐 Checking dependencies 

Also tried pnpm dlx create-nx-workspace from scratch but it hangs on the second step

Creating your workspace in test-nx

Expected Behavior

Inits operations should complete gracefully

GitHub Repo

No response

Steps to Reproduce

  1. pnpm dlx create-nx-workspace

Nx Report

❯ pnpm dlx nx report                      
Packages: +115
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 123, reused 111, downloaded 4, added 115, done
.cache/pnpm/dlx/ogenweua4lihpne4pbq6bewrt4/1915f46eda6-1d714/node_modules/.pnpm/[email protected]/node_modules/nx: Running postinstall script, done in 373ms

(...and nothing for at least 20min)

Failure Logs

No response

Package Manager Version

PNPM v9.7.0 or NPM v10.5.0

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

A common logs I see with NODE_DEBUG=* on all the nx command is

MODULE 121282: RELATIVE: requested: ./error-types from parent.id /home/******/node_modules/.pnpm/[email protected]_@[email protected]/nod
e_modules/nx/src/project-graph/build-project-graph.js
MODULE 121282: looking for ["/home/*******/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx/src/project-graph"]
NET 121243: pipe true /tmp/plugin121243-0.sock
NET 121243: connect: attempting to connect to /tmp/plugin121243-0.sock:NaN (addressType: NaN)
MODULE 121282: Module._load REQUEST ./utils/project-configuration-utils parent: /home/*********/node_modules/.pnpm/[email protected]_@swc+
[email protected]/node_modules/nx/src/project-graph/build-project-graph.js
MODULE 121282: RELATIVE: requested: ./utils/project-configuration-utils from parent.id /home/*******/node_modules/.pnpm/[email protected].
7_@[email protected]/node_modules/nx/src/project-graph/build-project-graph.js
MODULE 121282: looking for ["/home/*********/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx/src/project-graph"]
NET 121243: createConnection [
  { path: '/tmp/plugin121243-1.sock' },
  [Function (anonymous)],
  [Symbol(normalizedArgs)]: true
]

The addressType: NaN caught my eyes but I don't know if it's relevant. But this logs keeps repeating until it hangs on

MODULE 121275: looking for ["/home/*******/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx/src/plugins/js"]
MODULE 121275: Module._load REQUEST child_process parent: /home/*******/node_modules/.pnpm/[email protected]_@[email protected]/node_modul
es/nx/src/plugins/js/index.js
MODULE 121275: load built-in module child_process
STREAM 121243: push <Buffer 7b 22 74 79 70 65 22 3a 22 6c 6f 61 64 2d 72 65 73 75 6c 74 22 2c 22 70 61 79 6c 6f 61 64 22 3a 7b 22 6e 61 6d 65 22 3a 2
2 6e 78 2f 6a 73 2f 64 65 70 ... 205 more bytes>
TIMER 121243: unenroll: list empty
STREAM 121243: maybeReadMore read 0
STREAM 121243: read 0
STREAM 121243: need readable true
STREAM 121243: length less than watermark true
STREAM 121243: do read
NET 121243: _read - n 16384 isConnecting? false hasHandle? true

I tried emptying /tmp, restarting, nx clean but the issue persists

@cefeboru
Copy link

Not sure if the issue is related, but I get a similar behavior when upgrading from NX 18 to NX 19. My installation gets stuck on the postinstall nx step forever. If I ignore the scripts when installing modules, subsequent nx commands get stuck as well.

Using:
Node v18.16.0
PNPM 8.12.1
OS Sonoma 14.4.1 (23E224)
Apple M1 Pro

@DanLatimer
Copy link

We have some members of our team experiencing this issue too, one reverted to the last version of nx we were on (19.2.3) to get around this fail to install. Would be great to get a fix for this.

@FrozenPandaz
Copy link
Collaborator

This occurs on create-nx-workspace for you? Which answers did you provide to the prompts? If possible, is there a repo that I can run nx init in to reproduce the issue?

Can you also see if any of these environment variables resolve the issue?

  • NX_DAEMON=false
  • NX_ISOLATE_PLUGINS=false

@JbIPS
Copy link
Author

JbIPS commented Aug 19, 2024

It try create-nx-workspace with the env vars, same result

❯ NX_DAEMON=false NX_ISOLATE_PLUGINS=false pnpm dlx create-nx-workspace
Packages: +56
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 56, reused 55, downloaded 1, added 56, done

 NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

✔ Where would you like to create your workspace? · test-nx
✔ Which stack do you want to use? · none
✔ Package-based monorepo, integrated monorepo, or standalone project? · integrated
✔ Which CI provider would you like to use? · gitlab

 NX   Creating your v19.6.1 workspace.

✔ Installing dependencies with pnpm
⠏ Creating your workspace in test-nx
[Hangs indefinitely...]

I tried to use what seems like basic option to remove complexity but nothing changed.

@blacksand
Copy link

blacksand commented Aug 20, 2024

I have the same problem, both create-nx-workspace and nx migrate stop responding at postinstall.

The last version that worked is v19.4.4

MacBookPro intel cpu
node: 20.16.0
pnpm: 9.6.0

Copy link

This issue has been automatically marked as stale because no reproduction was provided within 7 days.
Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue.
Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues.
This issue will be closed in 21 days if a reproduction is not provided.
If a reproduction has been provided, please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Aug 28, 2024
@tonivj5
Copy link

tonivj5 commented Aug 28, 2024

I've suffered from this issue in bitbucket pipelines... 😕 Sometimes it takes so many time to run postinstall

@github-actions github-actions bot removed the stale label Aug 29, 2024
@Markus-Ende
Copy link

this is the same: #20270

Copy link

This issue has been automatically marked as stale because no reproduction was provided within 7 days.
Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue.
Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues.
This issue will be closed in 21 days if a reproduction is not provided.
If a reproduction has been provided, please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Sep 11, 2024
@github-actions github-actions bot removed the stale label Sep 24, 2024
@keriati
Copy link

keriati commented Sep 27, 2024

Similar issue: #28148

@lennybakkalian
Copy link

lennybakkalian commented Oct 1, 2024

I have the same problem with pnpm/npm/yarn.
It works on my second mac with the exact same repository and node version, so it must be something outside the repository. - Thats prob the reason why no one can reproduce this bug.

NX 19.8.2, Node v20.17.0, PNPM 9.11.0, Apple M2 Pro

Edit:
I have found a workaround:
if i move the project to the /tmp folder and run pnpm i from there, it seems to work.

although i killed all processes accessing files in the project with lsof, the postinstall script only works in /tmp because the files are magically not locked in get_files. unfortunately the nx setup is too complex for me to debug it myself.

Copy link

This issue has been automatically marked as stale because no reproduction was provided within 7 days.
Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue.
Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues.
This issue will be closed in 21 days if a reproduction is not provided.
If a reproduction has been provided, please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Oct 10, 2024
@tonivj5
Copy link

tonivj5 commented Oct 10, 2024

Up

@github-actions github-actions bot removed the stale label Oct 11, 2024
Copy link

This issue has been automatically marked as stale because no reproduction was provided within 7 days.
Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue.
Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues.
This issue will be closed in 21 days if a reproduction is not provided.
If a reproduction has been provided, please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Oct 18, 2024
@aagnone3
Copy link

Bump

@github-actions github-actions bot removed the stale label Oct 19, 2024
@phil-monroe
Copy link

I can also confirm that removing/moving the .gitignore in a parent folder to the repo I am trying to setup nx in fixed my issue. The thing that I think is interesting, the .gitignore that was causing issues for me lived in my user's home folder, multiple levels higher than the repository I was trying to initialize nx in.

/Users/phil/development/{company_name}/{git_repository_name}  <-- This is the git repo I was initializing with nx
/Users/phil/.gitignore                                        <-- This is my .gitignore for my user dotfiles

I use the "dotfiles" approach to synchronize my common laptop configurations across my laptops/workstations and never would have guessed this would have caused this issue.

Thank you @90dy for pointing to that stack overflow question which helped me connect the dots to my dotfiles setup.

I am definitely new to the nx toolset/mindset, but is there a reason that nx would need to crawl directories higher than the folder you are calling nx init inside of?

@90dy
Copy link

90dy commented Jan 24, 2025

I am definitely new to the nx toolset/mindset, but is there a reason that nx would need to crawl directories higher than the folder you are calling nx init inside of?

I agree it shouldn't

Copy link

github-actions bot commented Feb 1, 2025

This issue has been automatically marked as stale because no reproduction was provided within 7 days.
Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue.
Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues.
This issue will be closed in 21 days if a reproduction is not provided.
If a reproduction has been provided, please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Feb 1, 2025
@Lazerbeak12345
Copy link

Lazerbeak12345 commented Feb 1, 2025

Up

a few recent repros:

  1. Nx operations hangs indefinitely #27494 (comment)
  2. Nx operations hangs indefinitely #27494 (comment)
  3. Nx operations hangs indefinitely #27494 (comment)
  4. Nx operations hangs indefinitely #27494 (comment) (A docker file!)
  5. Nx operations hangs indefinitely #27494 (comment)
  6. Nx operations hangs indefinitely #27494 (comment)

automatically closing "stale" issues after only 7 days is a bad practice.

@FrozenPandaz would you please remove the blocked label?

@mfisher87
Copy link

https://jacobtomlinson.dev/posts/2024/most-stale-bots-are-anti-user-and-anti-contributor-but-they-dont-have-to-be/

@Lazerbeak12345
Copy link

Lazerbeak12345 commented Feb 1, 2025

It seems the bot is configured to autoremove the tag if the issue is updated by the original poster. Ideally, a user should be able to tell the bot that they've reproduced the bug so a human can confirm and reprioritize.

remove-stale-when-updated: true

@JbIPS do these recreations of the issue look correct? If so, could you try editing the issue post?

@github-actions github-actions bot removed the stale label Feb 2, 2025
OysteinAmundsen added a commit to OysteinAmundsen/home that referenced this issue Feb 4, 2025
Does not work properly at the moment, because of:
* issues with cypress and bun: cypress-io/cypress#28962
* issues with nx hang: nrwl/nx#27494
OysteinAmundsen added a commit to OysteinAmundsen/home that referenced this issue Feb 4, 2025
Does not work properly at the moment, because of:
* issues with cypress and bun:
cypress-io/cypress#28962
* issues with nx hang: nrwl/nx#27494

These issues will have to be addressed later. But for now, I'll merge.
@gpichot
Copy link

gpichot commented Feb 4, 2025

Hello,
I am trying to use nx again (had some issues in the past with the "hanging" process).
If it can helps: I encountered the same issue in my current setup.
My home directory is gitted (.gitignore with * and I only commit some files like zsh config, .config files etc).
I tried to create a nx repository inside my ~/Dev/my-workspace, but the process always hangs.

/Users/User1/
├──  .git <---- Home repo
├──  Dev/workspace
│             └── .git  <--- Workspace repo

I created a new workspace in /opt/dev/workspace and it worked this time.

So, and it may only be related to my case, but if nx is installed or run in nested "git root" directories it seems it will hang for an unknown reason.

@mfisher87
Copy link

I created a new workspace in /opt/dev/workspace and it worked this time.

I workaround this in a similar way. It's definitely not only you 😁

vmasek added a commit to code-pushup/cli that referenced this issue Feb 10, 2025
vmasek added a commit to code-pushup/cli that referenced this issue Feb 11, 2025
vmasek added a commit to code-pushup/cli that referenced this issue Feb 11, 2025
Copy link

This issue has been automatically marked as stale because no reproduction was provided within 7 days.
Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue.
Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues.
This issue will be closed in 21 days if a reproduction is not provided.
If a reproduction has been provided, please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Feb 12, 2025
@mfisher87
Copy link

mfisher87 commented Feb 12, 2025

I'm curious why this issue isn't getting the attention it needs to be productive (removing the needs repro label). Is the maintenance team accustomed to this issue being very noisy without progress, and stopped checking? Would it be helpful for @JbIPS to rename this issue to include the cause of the issue in the title? E.g.:

Nx hangs indefinitely due to interactions with .gitignore files outside the project directory

This makes it more clear that (1) this can impact a lot of people (2) it can be really hard to debug (3) we have debugged and know the root cause.

If might also be useful if @JbIPS can add the reproductions to the description of the issue.

@marcin-repec
Copy link

This makes it more clear that (1) this can impact a lot of people (2) it can be really hard to debug (3) we have debugged and know the root cause.

(3) I would add that we know only one of the causes - in my case, I don't have any .gitignore or .git above nx repo, and it hangs anyway

@mfisher87
Copy link

mfisher87 commented Feb 12, 2025

Perhaps we should create a new issue for the one cause we know of and can repro, and leave this issue open for the other potential causes?

@github-actions github-actions bot removed the stale label Feb 13, 2025
@navarrovmn
Copy link

Leaving this here as it might help someone else. I also thought I didn't have any .gitignore above my nx repo, but it turns out I had one in my home (~/.gitignore) with the * content that was created by venv (another tool altogether).

After I erased that .gitignore, the command stopped hanging.

@ptrpiero
Copy link

Leaving this here as it might help someone else. I also thought I didn't have any .gitignore above my nx repo, but it turns out I had one in my home (~/.gitignore) with the * content that was created by venv (another tool altogether).

After I erased that .gitignore, the command stopped hanging.

Yes I had the same issue! Thank you for pointing it out!

Copy link

github-actions bot commented Mar 4, 2025

This issue has been automatically marked as stale because no reproduction was provided within 7 days.
Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue.
Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues.
This issue will be closed in 21 days if a reproduction is not provided.
If a reproduction has been provided, please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Mar 4, 2025
@zblach-postman
Copy link

I am able to reproduce this issue with both nx versions 19.6.1 and 20.4.6. the nx postinstall hook hangs indefinitely if there's a .gitignore containing * in a parent directory.

@github-actions github-actions bot removed the stale label Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests