nest: [9.x.x] Duplicate Provider names don't get shown in REPL-debug() function

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Given the following Diagram:

graph TD;
  AppModule((AppModule))-->CatModule((CatModule))
  AppModule-->AppService_A>AppService]
  AppModule-->foo_A>provide: 'Foo', useValue: 'bar']

  CatModule-->AppService_B>AppService]
  CatModule-->foo_B>provide: 'Foo', useValue: 'barbaz']
  CatModule-->CatService>CatService]

Both the AppModule and CatModule have providers with the same name but different implementations/instances. When using the NestJS repl() method and print a debug() statement in order to list the application context, the AppService & Foo provider does not get listed within the CatModule.

[Nest] 5340  - 07/08/2022, 11:18:42 AM     LOG [NestFactory] Starting Nest application...
[Nest] 5340  - 07/08/2022, 11:18:42 AM     LOG [InstanceLoader] CatModule dependencies initialized
[Nest] 5340  - 07/08/2022, 11:18:42 AM     LOG [InstanceLoader] AppModule dependencies initialized
[Nest] 5340  - 07/08/2022, 11:18:42 AM     LOG REPL initialized
> debug()

AppModule:
 - controllers:
  ◻ AppController
 - providers:
  ◻ AppService
  ◻ Foo
CatModule:
 - providers:
  ◻ CatService

Minimum reproduction code

https://github.com/BrunnerLivio/nestjs-repro-duplicate-provider-repl

Steps to reproduce

  1. npm ci
  2. npm run start:dev
  3. Write debug() within REPL console

Expected behavior

Should list all providers

[Nest] 5340  - 07/08/2022, 11:18:42 AM     LOG [NestFactory] Starting Nest application...
[Nest] 5340  - 07/08/2022, 11:18:42 AM     LOG [InstanceLoader] CatModule dependencies initialized
[Nest] 5340  - 07/08/2022, 11:18:42 AM     LOG [InstanceLoader] AppModule dependencies initialized
[Nest] 5340  - 07/08/2022, 11:18:42 AM     LOG REPL initialized
$ debug()

AppModule:
 - controllers:
  ◻ AppController
 - providers:
  ◻ AppService
  ◻ Foo
CatModule:
 - providers:
  ◻ CatService
+ ◻ AppService
+ ◻ Foo

Package

Other package

No response

NestJS version

9.0.0

Packages versions

platform-express version : 9.0.0
schematics version       : 9.0.1
testing version          : 9.0.0
common version           : 9.0.0
core version             : 9.0.0
cli version              : 9.0.0

Node.js version

16.15.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (14 by maintainers)

Most upvoted comments

Sorry for this issue. You just released an AWESOME Nest V9 and now I already have to report an edge case 😛 Low prio obviously (in case you consider this as unexpected behavior), I am just playing dumb user haha

@micalevisk that’s how NestApplicationContext instance behaves by default (this isn’t a bug)

Guys, what’s the solution for this issue? I can code it but I didn’t understood what needs to be done