Sync generator causes infinite loop and terminal freeze in NX
simeon-raykov opened this issue · 1 comments
Current Behavior
Hey folks,
We recently discovered this NX feature: Sync Generators. We thought it would be useful to run a generator before executing a task (instead of creating an NX run command task with the generator inside it). We tested it, but it seems that the node process enters an infinite loop, and we have to manually kill it to continue using NX (the terminal freezes).
Our case involves a Storybook with components, and we wanted to implement variable visualization within it—to list the variables used in the components. We implemented an NX generator that scans the component library's SCSS files and converts them into an object, which we later import into our MDX Storybook files. The issue is that while I was developing the feature, there were no problems with the sync generator. However, my colleagues reported that their terminals froze when they tried to run the generator.
To debug the problem, I did a fresh install of the project and discovered that it was the syncGenerator feature causing the issue. After switching to NX run commands with dependsOn, the problem no longer occurred.
Expected Behavior
When using the sync generator feature in NX, the generator should execute successfully before running the task, without causing the node process to enter an infinite loop or freezing the terminal. The process should complete normally, allowing the developer to continue using NX.
GitHub Repo
No response
Steps to Reproduce
- Create an NX project with Storybook and a component that uses it.
- Create a generator that scans SCSS files in a component library and converts the variables into an object (creating a TS file for each story). (This could be done differently; I believe any fs manipulations could cause the problem)
- Configure the generator to run before executing the build Storybook task.
- Observe that the Node process enters an infinite loop, and the terminal freezes, requiring a manual termination to resume using NX.
( If the issue is not reproducible try to recreate the project )
Nx Report
Node : 20.11.0
OS : darwin-arm64
Native Target : aarch64-macos
yarn : 3.6.1
nx (global) : 20.2.2
nx : 20.1.2
@nx/js : 20.1.2
@nx/jest : 20.1.2
@nx/eslint : 20.1.2
@nx/workspace : 20.1.2
@nx/cypress : 20.1.2
@nx/devkit : 20.1.2
@nx/eslint-plugin : 20.1.2
@nx/next : 20.1.2
@nx/playwright : 20.1.2
@nx/plugin : 20.1.2
@nx/react : 20.1.2
@nx/storybook : 20.1.2
@nx/vite : 20.1.2
@nx/web : 20.1.2
@nx/webpack : 20.1.2
nx-cloud : 19.1.0
typescript : 5.4.2
---------------------------------------
Community plugins:
@jscutlery/semver : 5.2.2
@nx-tools/nx-container : 6.0.1
---------------------------------------
Local workspace plugins:
@ps/web-fusion-components
@ps/web-martech-cms-types
@ps/web-shared-analytics
@ps/web-fusion-icons
@ps/web-core-tools
@ps/web-core-intl
Failure Logs
Package Manager Version
No response
Operating System
- macOS
- Linux
- Windows
- Other (Please specify)
Additional Information
No response
Thanks for reporting this!
Please provide a repo with a minimal reproduction so we can properly understand the issue and troubleshoot it. The @nx/js:typescript-sync
generator performs fs operations, and it doesn't cause an infinite loop, so it might be specific to the operations done in your sync generator. Also, please try with the latest version of Nx if possible. Several stability fixes landed in the last few versions.