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): Skip dependencies already added (avoid circular dependencies) #9744

Merged
merged 3 commits into from May 4, 2022
Merged

fix(core): Skip dependencies already added (avoid circular dependencies) #9744

merged 3 commits into from May 4, 2022

Conversation

danielsharvey
Copy link
Contributor

The project utility method collectDependentProjectNodesNames() produces a stack overflow (e.g. producing project dependencies for tailwind.config.js when circular dependencies exist.

Fix by adding loop detection for "already added" dependencies.

Current Behavior

Currently, when a circular dependency exists, operations like (for example) a development build for an Angular app including Tailwind produces a stack overflow as follows:

⠇ Generating browser application bundles (phase: building)...Error: createGlobPatternsForDependencies: Error when generating globs.
Maximum call stack size exceeded
    at createGlobPatternsForDependencies (/<project-dir>/node_modules/@nrwl/workspace/src/utilities/generate-globs.js:31:15)
    at createGlobPatternsForDependencies (/<project-dir>/node_modules/@nrwl/angular/tailwind.js:12:71)
    at Object.<anonymous> (/<project-dir>/apps/sandbox/tailwind.config.js:72:8)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at Module.require (/<project-dir>/node_modules/nx/src/compat/compat.js:14:40)
    at require (internal/modules/cjs/helpers.js:92:18)
    at getTailwindConfig (/<project-dir>/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:65:53)
    at /<project-dir>/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:124:92
    at /<project-dir>/node_modules/tailwindcss/lib/processTailwindFeatures.js:43:11
    at plugins (/<project-dir>/node_modules/tailwindcss/lib/index.js:20:104)
    at LazyResult.runOnRoot (/<project-dir>/node_modules/@angular-devkit/build-angular/node_modules/postcss/lib/lazy-result.js:339:16)
    at LazyResult.runAsync (/<project-dir>/node_modules/@angular-devkit/build-angular/node_modules/postcss/lib/lazy-result.js:393:26)

[createGlobPatternsForDependencies] WARNING: There was no ProjectGraph available to read from, returning an empty array of glob patterns

Expected Behavior

Ideally, circular dependencies should be detected and recursion avoided.

Related Issue(s)

I've taken a similar approach to #2022.

@nx-cloud
Copy link

nx-cloud bot commented Apr 8, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit f4b9faa. 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 13 targets

Sent with 💌 from NxCloud.

@vercel
Copy link

vercel bot commented Apr 8, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nrwl/nx-dev/9MxPYpyPxFkFrmwti8JkCfzpf11z
✅ Preview: Ignored

[Deployment for e3928c5 canceled]

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.

Thank you for your contribution! LGTM 🎉

danielsharvey and others added 3 commits April 29, 2022 14:44
The project utility method `collectDependentProjectNodesNames()`
produces a stack overflow (e.g. producing project dependencies for
`tailwind.config.js` when circular dependencies exist.

Fix by adding loop detection for "already add" dependencies.
@vercel
Copy link

vercel bot commented Apr 29, 2022

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

Name Status Preview Updated
nx-dev ✅ Ready (Inspect) Visit Preview Apr 29, 2022 at 6:51PM (UTC)

@FrozenPandaz FrozenPandaz enabled auto-merge (squash) April 29, 2022 19:00
@FrozenPandaz FrozenPandaz self-assigned this Apr 29, 2022
@FrozenPandaz FrozenPandaz merged commit 8e4a38e into nrwl:master May 4, 2022
@danielsharvey danielsharvey deleted the fix/circular-dependencies branch May 5, 2022 03:29
@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
Development

Successfully merging this pull request may close these issues.

None yet

2 participants