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

Migration failure causing nx dependency graph to break #12583

Closed
ajwootto opened this issue Oct 13, 2022 · 3 comments · Fixed by #12628
Closed

Migration failure causing nx dependency graph to break #12583

ajwootto opened this issue Oct 13, 2022 · 3 comments · Fixed by #12628

Comments

@ajwootto
Copy link
Contributor

ajwootto commented Oct 13, 2022

Current Behavior

In two separate Nx repositories, when I've upgraded to newer versions (most recently from 14.1.4 to 14.8.3) there ends up being an issue with the migrations which causes the whole Nx dependency graph to break for unclear reasons (eg. when I run nx dep-graph it just shows a large flat list of all my packages rather than a tree). Another symptom is that the package.json output of the built package / application (when using the generatePackageJson option) ends up with a blank dependencies list.

The fix for the problem appears to be this
#10785 (comment)

While I managed to track this down both times after several hours of troubleshooting, it seems like Nx should be fixing this scenario with a migration that corrects the problem. I don't fully understand what migration caused the original issue since it isn't mentioned in that comment.

Expected Behavior

nx migrate should result in a working repository after migrations are finished.

Whatever migration issue caused this issue to begin with should be retroactively fixed by a new migration.

Steps to Reproduce

It's not exactly clear what versions or upgrade paths have caused this issue, all I can say is that I've now run into it twice on two separate repositories which were updated at different times through different versions of Nx. It seems like others will run into this to, and the symptom of it is basically that Nx becomes silently nonfunctional with no error messages.

Environment


   Node : 16.17.0
   OS   : darwin arm64
   yarn : 3.1.0

   nx : 14.8.3
   @nrwl/angular : Not Found
   @nrwl/cypress : 14.8.3
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.8.3
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 14.8.3
   @nrwl/expo : Not Found
   @nrwl/express : 14.8.3
   @nrwl/jest : 14.8.3
   @nrwl/js : 14.8.3
   @nrwl/linter : 14.8.3
   @nrwl/nest : 14.8.3
   @nrwl/next : Not Found
   @nrwl/node : 14.8.3
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : 14.8.3
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : 14.8.3
   @nrwl/webpack : 14.8.3
   @nrwl/workspace : 14.8.3
   typescript : 4.8.4

Edit: After discussions on Slack, the problem appears to be specifically with the migration to 14.2 that was meant to enable analyzeSourceFiles for nx repos that extend the npm preset. The default value for that was changed to false in 14.2, so a migration was supposed to add the true setting back in to maintain backwards compatibility. However, in my case this migration did not appear to work.

@FrozenPandaz
Copy link
Collaborator

FrozenPandaz commented Oct 13, 2022

There is a migration that should happen when moving to or past 14.2.0.

I generated a new 14.1.4 workspace with npx create-nx-workspace@14.1.4 --preset core and then ran the migrations via npm i && nx migrate latest && nx migrate --run-migrations and the following config was added successfully.

Can you share your repo before migrating? Or at least an nx.json file?

  "pluginsConfig": {
    "@nrwl/js": {
      "analyzeSourceFiles": true
    }
  }

@ajwootto
Copy link
Contributor Author

ajwootto commented Oct 14, 2022

@FrozenPandaz there was a discussion about this in Slack
https://nrwlcommunity.slack.com/archives/CMFKWPU6Q/p1665690716270709

My understanding is that this only would affect repos where the nx.json extends from the npm.json preset (which it did in my case).

edit: this is the full nx.json before migration:

{
  "extends": "nx/presets/npm.json",
  "npmScope": "devcycle",
  "workspaceLayout": {
    "libsDir": "lib",
    "appsDir": "services"
  },
  "implicitDependencies": {
    "package.json": {
      "dependencies": "*",
      "devDependencies": "*"
    },
    ".eslintrc.json": "*",
    ".circleci/config.yml": "*",
    "cf-workers/client-sdk-api/.env": [
      "client-sdk-api"
    ],
    ".generated/environments/local.env": "*"
  },
  "tasksRunnerOptions": {
    "default": {
      "runner": "nx/tasks-runners/default",
      "options": {
        "cacheableOperations": [
          "build",
          "test",
          "lint",
          "check-types",
          "package",
          "prepare"
        ],
        "parallel": 3
      }
    }
  },
  "targetDependencies": {
    "build": [
      {
        "target": "build",
        "projects": "dependencies"
      }
    ],
    "prepare": [
      {
        "target": "prepare",
        "projects": "dependencies"
      }
    ],
    "package": [
      {
        "target": "package",
        "projects": "dependencies"
      }
    ]
  },
  "affected": {
    "defaultBase": "main"
  },
  "cli": {
    "defaultCollection": "@nrwl/nest"
  },
  "generators": {
    "@nrwl/web:application": {
      "style": "css",
      "linter": "eslint",
      "unitTestRunner": "jest",
      "e2eTestRunner": "cypress"
    },
    "@nrwl/web:library": {
      "style": "css",
      "linter": "eslint",
      "unitTestRunner": "jest"
    }
  },
  "defaultProject": "api"
}

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

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

Successfully merging a pull request may close this issue.

2 participants