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

Broken Nest.js app when migrating from 13.2.x to 13.4.x #8446

Closed
aboqasem opened this issue Jan 9, 2022 · 3 comments · Fixed by #8784
Closed

Broken Nest.js app when migrating from 13.2.x to 13.4.x #8446

aboqasem opened this issue Jan 9, 2022 · 3 comments · Fixed by #8784

Comments

@aboqasem
Copy link

aboqasem commented Jan 9, 2022

Current Behavior

I have a broken Nest.js app in production but working in development, the error:

[Nest] 13815  - 01/07/2022, 12:52:45 PM   ERROR [ExceptionHandler] Nest can't resolve dependencies of the u (?, u). Please make sure that the argument i at index [0] is available in the u context.

Potential solutions:
- If i is a provider, is it part of the current u?
- If i is exported from a separate @Module, is that module imported within u?
  @Module({
    imports: [ /* the Module containing i */ ]
  })

Error: Nest can't resolve dependencies of the u (?, u). Please make sure that the argument i at index [0] is available in the u context.

Potential solutions:
- If i is a provider, is it part of the current u?
- If i is exported from a separate @Module, is that module imported within u?
  @Module({
    imports: [ /* the Module containing i */ ]
  })

Everything is minified that I cant see the name of the modules, and to get it working I traced back to a commit with nx migrate latest and the diff is:

package.json:
-    "@nrwl/next": "13.4.2",
-    "@nrwl/cli": "13.4.2",
-    "@nrwl/cypress": "13.4.2",
-    "@nrwl/eslint-plugin-nx": "13.4.2",
-    "@nrwl/jest": "13.4.2",
-    "@nrwl/js": "13.4.2",
-    "@nrwl/linter": "13.4.2",
-    "@nrwl/nest": "13.4.2",
-    "@nrwl/node": "13.4.2",
-    "@nrwl/react": "13.4.2",
-    "@nrwl/tao": "13.4.2",
-    "@nrwl/web": "13.4.2",
-    "@nrwl/workspace": "13.4.2",
+    "@nrwl/next": "13.2.3",
+    "@nrwl/cli": "13.2.3",
+    "@nrwl/cypress": "13.2.3",
+    "@nrwl/eslint-plugin-nx": "13.2.3",
+    "@nrwl/jest": "13.2.3",
+    "@nrwl/linter": "13.2.3",
+    "@nrwl/nest": "13.2.3",
+    "@nrwl/node": "13.2.3",
+    "@nrwl/react": "13.2.3",
+    "@nrwl/tao": "13.2.3",
+    "@nrwl/web": "13.2.3",
+    "@nrwl/workspace": "13.2.3",

workspace.json:
       "projectType": "library",
       "targets": {
         "build": {
-          "executor": "@nrwl/js:tsc",
+          "executor": "@nrwl/workspace:tsc",
           "outputs": ["{options.outputPath}"],
           "options": {
             "outputPath": "dist/libs/shared/mapped-types",

Without these changes, class names are not minified and the production build works fine.

Expected Behavior

For the Nest.js app to work as it did prior to upgrading and adding @nrwl/js executor.

Steps to Reproduce

I honestly do not know where the problem is but I suspect it is from the production build process in 13.4.x, because when I downgrade back to 13.2.xclasses are not minified and the error is totally gone.

Failure Logs

Provided above.

Environment

  Node : 14.18.1
  OS   : darwin x64
  pnpm : 6.22.2

  nx : undefined
  @nrwl/angular : undefined
  @nrwl/cli : 13.4.2
  @nrwl/cypress : 13.4.2
  @nrwl/devkit : undefined
  @nrwl/eslint-plugin-nx : 13.4.2
  @nrwl/express : undefined
  @nrwl/jest : 13.4.2
  @nrwl/linter : 13.4.2
  @nrwl/nest : 13.4.2
  @nrwl/next : 13.4.2
  @nrwl/node : 13.4.2
  @nrwl/nx-cloud : undefined
  @nrwl/react : 13.4.2
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/tao : 13.4.2
  @nrwl/web : 13.4.2
  @nrwl/workspace : 13.4.2
  @nrwl/storybook : undefined
  @nrwl/gatsby : undefined
  typescript : 4.5.4
  rxjs : 7.5.1
  ---------------------------------------
  Community plugins:
  	 @nrwl/js: 13.4.2
@aboqasem aboqasem changed the title Broken Nest.js app when migrating to @nrwl/js executor Broken Nest.js app when migrating from 13.2.x to 13.4.x Jan 9, 2022
@hrmcdonald
Copy link

hrmcdonald commented Jan 11, 2022

I had a 13.3.x update break a build a well. I was able to fix it by setting "optimizations" to false for the NestJS production build configuration.

bilalshaikh42 added a commit to biosimulations/biosimulations that referenced this issue Jan 16, 2022
disabled optimization in prod builds as this uses minification, which causes class names to change.
NestJS heavilty utilizes reflection for many features which break when this change occurs.

see nrwl/nx#8446
closes #4061
closes #4036
jonrkarr pushed a commit to biosimulations/biosimulations that referenced this issue Jan 18, 2022
disabled optimization in prod builds as this uses minification, which causes class names to change.
NestJS heavilty utilizes reflection for many features which break when this change occurs.

see nrwl/nx#8446
closes #4061
closes #4036
@eva-devs
Copy link

I also run into that problem. Even the module names in the bootstrap log were minified:

[Nest] 4 LOG [InstanceLoader] _ dependencies initialized +13ms
[Nest] 4 LOG [InstanceLoader] MailerCoreModule dependencies initialized +1ms
[Nest] 4 LOG [InstanceLoader] a dependencies initialized +1ms
[Nest] 4 LOG [InstanceLoader] WinstonModule dependencies initialized +2ms
[Nest] 4 LOG [InstanceLoader] ServeStaticModule dependencies initialized +1ms
[Nest] 4 LOG [InstanceLoader] ServeStaticModule dependencies initialized +0ms
[Nest] 4 LOG [InstanceLoader] _ dependencies initialized +0ms
[Nest] 4 LOG [InstanceLoader] a dependencies initialized +1ms
[Nest] 4 LOG [InstanceLoader] l dependencies initialized +1ms
[Nest] 4 LOG [InstanceLoader] l dependencies initialized +1ms
[Nest] 4 LOG [InstanceLoader] GraphQLSchemaBuilderModule dependencies initialized +1ms
[Nest] 4 LOG [InstanceLoader] u dependencies initialized +1ms
[Nest] 4 LOG [InstanceLoader] _ dependencies initialized +2ms

@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 22, 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.

4 participants