Skip to content

A transient service uses another transient service #16097

@NicChoi

Description

@NicChoi

Is there an existing issue for this?

  • I have searched the existing issues

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

  1. npm i
  2. npm start
  3. 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?

  • macOS
  • Windows
  • Linux

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue has not been looked into

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions