Is there an existing issue for this?
Current behavior
A transient service (MyService) uses another transient service (MyLogger)
The constructor and the onModuleInit is called in the MyService
But the constructor or the onModuleInit is not called in the MyLogger
When use this.logger.error in the MyService, the logger instance is found and has error function
But the this.logger in the MyLogger is undefined
Minimum reproduction code
https://github.com/NicChoi/nestjs-transient
Steps to reproduce
- npm i
- npm start
- curl http://localhost:3000
Expected behavior
Request failure
this.logger is undefined in the MyLogger service
NestJS version
11.1.9
Packages versions
{
"name": "nestjs-transient",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
},
"dependencies": {
"@nestjs/common": "^11.1.9",
"@nestjs/core": "^11.1.9",
"@nestjs/platform-express": "^11.1.9",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2"
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.3",
"@eslint/js": "^9.39.2",
"@nestjs/cli": "^11.0.14",
"@nestjs/schematics": "^11.0.9",
"@types/express": "^5.0.6",
"@types/node": "^22.19.3",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.4",
"globals": "^16.5.0",
"prettier": "^3.7.4",
"source-map-support": "^0.5.21",
"ts-loader": "^9.5.4",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.50.0"
}
}
Node.js version
22.21.1
In which operating systems have you tested?
Other
No response
Is there an existing issue for this?
Current behavior
A transient service (MyService) uses another transient service (MyLogger)
The
constructorand theonModuleInitis called in theMyServiceBut the
constructoror theonModuleInitis not called in theMyLoggerWhen use
this.logger.errorin theMyService, the logger instance is found and haserrorfunctionBut the
this.loggerin theMyLoggeris undefinedMinimum reproduction code
https://github.com/NicChoi/nestjs-transient
Steps to reproduce
Expected behavior
Request failure
this.loggeris undefined in theMyLoggerserviceNestJS version
11.1.9
Packages versions
{ "name": "nestjs-transient", "version": "0.0.1", "description": "", "author": "", "private": true, "license": "UNLICENSED", "scripts": { "build": "nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "start": "nest start", "start:dev": "nest start --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix" }, "dependencies": { "@nestjs/common": "^11.1.9", "@nestjs/core": "^11.1.9", "@nestjs/platform-express": "^11.1.9", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.2" }, "devDependencies": { "@eslint/eslintrc": "^3.3.3", "@eslint/js": "^9.39.2", "@nestjs/cli": "^11.0.14", "@nestjs/schematics": "^11.0.9", "@types/express": "^5.0.6", "@types/node": "^22.19.3", "eslint": "^9.39.2", "eslint-config-prettier": "^10.1.8", "eslint-plugin-prettier": "^5.5.4", "globals": "^16.5.0", "prettier": "^3.7.4", "source-map-support": "^0.5.21", "ts-loader": "^9.5.4", "ts-node": "^10.9.2", "tsconfig-paths": "^4.2.0", "typescript": "^5.9.3", "typescript-eslint": "^8.50.0" } }Node.js version
22.21.1
In which operating systems have you tested?
Other
No response