Closed JustDoItSascha closed 2 years ago
Maybe it's related to https://github.com/nestjs/nest/issues/8872
@JustDoItSascha I really don't know if it's related.. but hear that: I just came to this issue through Google search. because I'm having the same issue. I saw your reference - and this second issue is an issue I created not a long time ago (and was closed without getting any help!)
so I don't know if it's related (because my current task is not regarding the logger - it's for upgrading nestjs from 7 to 8) but it might be..
EDIT: Ok, after getting a bit into-it I got remembered.
my issue (#8872) was that PinoLogger
was not acting like TRANSIENT - the first injection was ok, but the rest were same object!
The key point here is that I used nestjs 7!!
when updating to nestjs 8 - same project - it's getting to this crash you opened here.
so yes - they are highly related!!
and I didn't got any help from this repo, nor PinoLogger repo, nor nestjs Discord [only there they approved it's a bug - but no one took ownership to solve it]
I hope it'll get solved...
a reasonable workaround:
the issue is the inner Transient service cannot be found in outer module..
so if you add the Transient service to the providers
list of the outer module - it'll work!!
not the cleanest way - but helps to get forward.
@Injectable({ scope: Scope.TRANSIENT })
export class App2Service {}
@Module({
providers: [App2Service],
exports: [App2Service],
})
export class App2Module {}
@Injectable({ scope: Scope.TRANSIENT })
export class AppService {
constructor(private app2: App2Service) {}
}
@Module({
imports: [App2Module],
providers: [AppService, App2Service], // <-- Workaround here - App2Service was added
})
export class AppModule {
constructor(private appService: AppService) {}
}
Let's track this here https://github.com/nestjs/nest/pull/9322
Is there an existing issue for this?
Current behavior
When I have two services which are both Scope.TRANSIENT and the services are in different modules, I get this error:
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-k5mqcg
Steps to reproduce
Tested with 8.2.6
Expected behavior
That nest starts
Package
Other package
No response
NestJS version
8.2.6
Packages versions
Node.js version
16
In which operating systems have you tested?
Other
No response