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

Slow AppModule Dependencies Initialization After Upgrading to NestJS 11 #14552

Open
6 of 14 tasks
marefati110 opened this issue Feb 2, 2025 · 6 comments
Open
6 of 14 tasks
Labels
needs triage This issue has not been looked into

Comments

@marefati110
Copy link

marefati110 commented Feb 2, 2025

Current behavior

Description
After upgrading my project from NestJS 10 to 11, I noticed that the AppModule dependencies initialization step has become significantly slower.

Actual Behavior
The initialization process in NestJS 11 is much slower compared to NestJS 10.

NestJS 11:
Image

Minimum reproduction code

https://github.com/nestjs

Steps to reproduce

No response

Expected behavior

The application should initialize AppModule and its dependencies as quickly as in NestJS 10.
No significant performance degradation should occur due to the upgrade.

nestjs10:
Image

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

No response

Packages versions

{
	"name": "",
	"version": "0.0.1",
	"description": "",
	"author": "",
	"private": true,
	"license": "UNLICENSED",
	"scripts": {
		"prebuild": "rimraf dist",
		"build": "nest build",
		"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
		"start": "cross-env TZ=UTC nest start",
		"start:dev": "nest start --watch",
		"dev": "cross-env TZ=UTC nest start --watch",
		"start:debug": "nest start --debug --watch",
		"start:prod": "cross-env TZ=UTC node dist/src/main",
		"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix --max-warnings 0",
		"test": "jest --passWithNoTests",
		"test:watch": "jest --watch",
		"test:cov": "jest --coverage",
		"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
		"test:e2e": "jest --passWithNoTests --config ./test/jest-e2e.json",
		"test:e2e:watch": "jest --watch --passWithNoTests --config ./test/jest-e2e.json",
		"test:all": "npm run lint && npm run test && npm run test:e2e",
		"build:data": "fixtures ./fixtures --config ./fixtures/orm.config.ts --require=ts-node/register --require=tsconfig-paths/register -d",
		"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config migration/orm.config.ts",
		"typeorm:migrate": "npm run typeorm migration:generate -- -n portal",
		"typeorm:run": "npm run typeorm migration:run",
		"typeorm:revert": "npm run typeorm migration:revert",
		"typeorm:show": "npm run typeorm migration:show"
	},
	"dependencies": {
		"@nestjs/axios": "^4.0.0",
		"@nestjs/cache-manager": "^3.0.0",
		"@nestjs/cli": "^11.0.2",
		"@nestjs/common": "^11.0.7",
		"@nestjs/core": "^11.0.7",
		"@nestjs/jwt": "^11.0.0",
		"@nestjs/microservices": "^11.0.7",
		"@nestjs/passport": "^11.0.5",
		"@nestjs/platform-express": "^11.0.7",
		"@nestjs/platform-socket.io": "^11.0.7",
		"@nestjs/schedule": "^5.0.1",
		"@nestjs/schematics": "^11.0.0",
		"@nestjs/serve-static": "^5.0.1",
		"@nestjs/swagger": "^11.0.3",
		"@nestjs/terminus": "^11.0.0",
		"@nestjs/testing": "^11.0.7",
		"@nestjs/typeorm": "^11.0.0",
		"@nestjs/websockets": "^11.0.7",
		"@nimasfl/nest-minio": "^3.0.4",
		"@ntegral/nestjs-sentry": "^4.0.1",
		"@sentry/node": "^8.53.0",
		"@sentry/tracing": "^7.120.3",
		"@sentry/types": "^8.53.0",
		"@swc/cli": "^0.6.0",
		"@swc/core": "^1.10.12",
		"@types/async": "^3.2.24",
		"@types/cache-manager": "^4.0.6",
		"@types/express": "^5.0.0",
		"@types/lodash": "^4.17.15",
		"@types/moment-jalaali": "^0.7.9",
		"@types/multer": "^1.4.12",
		"@types/node": "^22.13.0",
		"@types/pg": "^8.11.11",
		"@types/request-ip": "0.0.41",
		"@types/socket.io": "^3.0.2",
		"@types/string-similarity": "^4.0.2",
		"@types/wuzzy": "^0.1.0",
		"@typescript-eslint/eslint-plugin": "^8.22.0",
		"@typescript-eslint/parser": "^8.22.0",
		"async": "^3.2.0",
		"axios": "^1.7.9",
		"bcryptjs": "^2.4.3",
		"cache-manager": "^6.4.0",
		"callsite": "^1.0.0",
		"cheerio": "^1.0.0",
		"class-transformer": "^0.5.1",
		"class-validator": "^0.14.1",
		"crawler": "^2.0.2",
		"cross-env": "^7.0.3",
		"deepmerge": "^4.3.1",
		"dotenv": "^16.4.7",
		"eslint": "^8.23.0",
		"eslint-config-prettier": "^9.1.0",
		"eslint-plugin-prettier": "^5.2.3",
		"eslint-plugin-unused-imports": "^4.1.4",
		"helmet": "^4.4.1",
		"kafkajs": "^2.2.4",
		"kavenegar": "^1.1.4",
		"lodash": "^4.17.21",
		"minio": "^8.0.4",
		"moment": "^2.30.1",
		"moment-jalaali": "^0.10.4",
		"moment-timezone": "^0.5.47",
		"nestjs-i18n": "^10.5.0",
		"nestjs-pino": "^4.3.0",
		"nestjs-real-ip": "^3.0.1",
		"passport": "^0.7.0",
		"passport-headerapikey": "^1.2.2",
		"passport-jwt": "^4.0.1",
		"persian-tools2": "^1.5.0",
		"pg": "^8.13.1",
		"pino-http": "^10.4.0",
		"pino-pretty": "^13.0.0",
		"prettier": "^3.4.2",
		"reflect-metadata": "^0.2.2",
		"request-ip": "^3.3.0",
		"rimraf": "^6.0.1",
		"rxjs": "^7.8.1",
		"sharp": "^0.33.5",
		"slugify": "^1.6.6",
		"string-similarity": "^4.0.4",
		"swagger-typescript-api": "^13.0.23",
		"swagger-ui-express": "^5.0.1",
		"ts-loader": "^9.5.2",
		"ts-node": "^10.9.2",
		"tsconfig-paths": "^4.2.0",
		"typeorm": "^0.3.20",
		"typeorm-fixtures-cli": "^4.1.0",
		"typescript": "^5.7.3",
		"wuzzy": "^0.1.8"
	},
	"devDependencies": {},
	"jest": {
		"moduleFileExtensions": [
			"js",
			"json",
			"ts"
		],
		"rootDir": "src",
		"testRegex": ".*\\.spec\\.ts$",
		"transform": {
			"^.+\\.(t|j)s$": "ts-jest"
		},
		"collectCoverageFrom": [
			"**/*.(t|j)s"
		],
		"coverageDirectory": "../coverage",
		"testEnvironment": "node"
	},
	"packageManager": "[email protected]+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
}

Node.js version

v22.12.0.

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@marefati110 marefati110 added the needs triage This issue has not been looked into label Feb 2, 2025
@micalevisk
Copy link
Member

Please provide a minimum reproduction repository. You can start one by running npm init nest in your terminal

why reproductions are required

@kamilmysliwiec
Copy link
Member

We can't help you without seeing your AppModule (at the very least)

@marefati110
Copy link
Author

Hi @micalevisk and @kamilmysliwiec,

I'll be creating a private repository. Please share an email address so I can grant you access.

@kamilmysliwiec
Copy link
Member

Please provide a minimum public reproduction repository (Git repository/StackBlitz/CodeSandbox project).

@micalevisk
Copy link
Member

@marefati110 you could create a private repo here on github and add me as contributor using my username

@marefati110
Copy link
Author

@micalevisk

I've set up a private registry for the project and added you.

https://github.com/marefati110/backend-nestjs11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

3 participants