nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
66.91k stars 7.55k forks source link

ModuleRef.get is not giving any output, code flow gets stucked on that #11864

Closed armaansharma786 closed 1 year ago

armaansharma786 commented 1 year ago

Is there an existing issue for this?

Current behavior

I want in my project without injecting service, want to use service method,

for that i am using moduleRef

in moduleRef i am using get function moduleRef.get(service, {strict: false});

but above line not returning anything and flow gets stucked there. i am using moduleRef.get fn inside onModuleInit but my application is not bootstrapping due to this, after 5- 10 mins it gives me error on terminal

Application bootstrap error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: RangeError: Invalid string length drpt-bo-backend | at String.replaceAll () drpt-bo-backend | at formatValue (node:internal/util/inspect:819:16) drpt-bo-backend | at formatProperty (node:internal/util/inspect:1920:11) drpt-bo-backend | at formatRaw (node:internal/util/inspect:1055:9) drpt-bo-backend | at formatValue (node:internal/util/inspect:841:10) drpt-bo-backend | at formatProperty (node:internal/util/inspect:1920:11) drpt-bo-backend | at formatRaw (node:internal/util/inspect:1055:9) drpt-bo-backend | at formatValue (node:internal/util/inspect:841:10) drpt-bo-backend | at inspect (node:internal/util/inspect:365:10) drpt-bo-backend | at PrismaService.i. (/usr/src/app/node_modules/@prisma/client/runtime/library.js:163:12958) drpt-bo-backend | This is caused by either a bug in Node.js or incorrect usage of Node.js internals. drpt-bo-backend | Please open an issue with this stack trace at https://github.com/nodejs/node/issues

Minimum reproduction code

dont know its a public issue

Steps to reproduce

No response

Expected behavior

If i am using moduleRef.get fn to extract instance of service provide, it should give me the instance of that service

Package

Other package

No response

NestJS version

9.2.0

Packages versions

 "@nestjs/axios": "^1.0.1",
    "@nestjs/bull": "^0.6.2",
    "@nestjs/common": "^9.2.1",
    "@nestjs/config": "^2.2.0",
    "@nestjs/core": "^9.2.1",
    "@nestjs/jwt": "^10.0.1",
    "@nestjs/passport": "^9.0.0",
    "@nestjs/platform-express": "^9.2.1",
    "@nestjs/serve-static": "^3.0.0",
    "@nestjs/swagger": "^6.2.1",

Node.js version

18.12.1

In which operating systems have you tested?

Other

No response

micalevisk commented 1 year ago

Please provide a minimum reproduction repository. You can start from this minimal project.

why reproductions are required

armaansharma786 commented 1 year ago

https://stackblitz.com/edit/nestjs-issue-minimum-repro-starter-puwul4?devtoolsheight=33&file=src%2Fapp.module.ts,src%2Ftwo%2Ftwo.service.ts,src%2Fone%2Fone.service.ts,src%2Fone%2Fone.module.ts,src%2Ftwo%2Ftwo.module.ts

in this its working fine

but why not in my own project, what should i check for that, because currently I am not able to build it, it gets stuck and after so much time error prints on the terminal that i have mentioned in the previous message

kamilmysliwiec commented 1 year ago

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.