Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microservice broken after update from 7 -> 8, docs provide no alternative from nestfactory.create with app.get() #8742

Closed
2 tasks done
Meywether opened this issue Dec 5, 2021 · 8 comments
Labels
needs triage This issue has not been looked into type: bug 😭

Comments

@Meywether
Copy link

Meywether commented Dec 5, 2021

Did you read the migration guide?

  • I have read the whole migration guide

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Potential Commit/PR that introduced the regression

No response

NestJS version

7-8

Describe the regression

Hi there,
thanks for your time.
I create my microservices by creating a INestApplication as seen here in this repo: https://github.com/Meywether/nestjs_ms1
After upgrading from 7 -> 8 and after consulting the migration guide I came to the result that my way of getting my config variables is not supported anymore. But the migration guide does not tell me how the handle this issue. Let me outline the problem:

I create my Nest application with nest-winston as a logger and need to get the variables from my config:
``
image

``
Since createMicroservice does not allow to inject my config service, containing the redis config, I need to workaround this in this way:
image

As you can already see line 65 is red -> This is also stated in the migration guide, that startAllMicroservices does not have any argument. But also with .then()... I can not get this running again.

Also with app.listen -> not working because app is not a instance of INestMicroservices.

Here the error:
image

Here is the main HTTP Repo: https://github.com/Meywether/nestjs_http_sample -> working with Nest 8
Here is the main Microservice Repo in broken state with config service: https://github.com/Meywether/nestjs_ms1

May I kindly ask for your help ?

Thank you very much in advance!

Minimum reproduction code

https://github.com/Meywether/nestjs_ms1 and https://github.com/Meywether/nestjs_http_sample

Input code

Expected behavior

Help to develop a different approach to inject config service.

Other

No response

Update: 05.12.2021- Nest 8 and Nest 7 communication via redis is also not possible due to redis 4 @ nest 8 and redis 3 @nest 7 updated depency of the main repo to cover this.
Update 05.12.2021 - Found an open discussion about a similar context. I think this one is related:
#2343

@Meywether Meywether added needs triage This issue has not been looked into type: bug 😭 labels Dec 5, 2021
@jmcdo29
Copy link
Member

jmcdo29 commented Dec 5, 2021

The microservice start method (whether in a hybrid application or a dedicated one) no longer takes a callback. It's just an async method. This worked for me (save for the fact that I had an invalid config)

  await app.startAllMicroservices();
  console.log("MS 1 is listening ....");

We make a general mention of this here, but we can update this to be more explicit if need be.

@jmcdo29 jmcdo29 closed this as completed Dec 5, 2021
@Meywether
Copy link
Author

@jmcdo29 thanks for your answer but using my test repo, mentioned above, I never come to the console.log:

image

Did you changed anything else within the repo ?

Best regards
Meywether

@jmcdo29
Copy link
Member

jmcdo29 commented Dec 5, 2021

Well, in your reproduction you didn't provide a way to run redis, so I didn't get any further r the invalid host error. Next time please provide as full minimum reproduction

@Meywether
Copy link
Author

Meywether commented Dec 5, 2021

@jmcdo29 this point goes to you, sorry my fault:
Please find here the redis docker container and I updated the repo with a .env sample
redis.zip

The identical redis container is running ( with a different password ) without any problems locally with nest 7 projects

@micalevisk
Copy link
Member

@Meywether run your code with NEST_DEBUG=true and DEBUG=* env vars

@Meywether
Copy link
Author

Meywether commented Dec 6, 2021

@micalevisk Very warm welcome to the discussion :)

I set the two variabes in .env:

and this is the output:

image

Can you see something ?

express:application set "x-powered-by" to true +0ms
express:application set "etag" to 'weak' +3ms
express:application set "etag fn" to [Function: generateETag] +0ms
express:application set "env" to 'development' +2ms
express:application set "query parser" to 'extended' +0ms
express:application set "query parser fn" to [Function: parseExtendedQueryString] +1ms
express:application set "subdomain offset" to 2 +0ms
express:application set "trust proxy" to false +1ms
express:application set "trust proxy fn" to [Function: trustNone] +1ms
express:application booting in development mode +0ms
express:application set "view" to [Function: View] +0ms
express:application set "views" to 'C:\Users\XXXXXX\Desktop\nestjs_probs\ms\views' +1ms
express:application set "jsonp callback name" to 'callback' +0ms
[NestWinston] Info 6.12.2021, 08:16:23 [NestFactory] Starting Nest application...

  • {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Resolving dependency Reflector in the Reflector provider (alias) - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for Reflector in InternalCoreModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Found Reflector in InternalCoreModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Resolving dependency HttpAdapterHost in the HttpAdapterHost provider (alias) - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for HttpAdapterHost in InternalCoreModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Found HttpAdapterHost in InternalCoreModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Resolving dependency String in the Logger provider - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for String in AppModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for String in ConfigModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for String in ConfigHostModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Resolving dependency Object in the Logger provider - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for Object in AppModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for Object in ConfigModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for Object in ConfigHostModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Resolving dependency Symbol(CONFIG_SERVICE) in the ConfigService provider - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for Symbol(CONFIG_SERVICE) in ConfigModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for Symbol(CONFIG_SERVICE) in ConfigHostModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Found Symbol(CONFIG_SERVICE) in ConfigHostModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Resolving dependency CONFIGURATION_TOKEN in the ConfigService provider - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for CONFIGURATION_TOKEN in ConfigHostModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Found CONFIGURATION_TOKEN
    in ConfigHostModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Resolving dependency CONFIGURATION(1dc97cb2-cd12-467a-959f-c645dc9420f8) in the ConfigService provider - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for CONFIGURATION(1dc97cb2-cd12-467a-959f-c645dc9420f8) in ConfigModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Found CONFIGURATION(1dc97cb2-cd12-467a-959f-c645dc9420f8) in ConfigModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Resolving dependency CONFIGURATION_TOKEN in the CONFIGURATION_LOADER provider - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for CONFIGURATION_TOKEN in ConfigModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for CONFIGURATION_TOKEN in ConfigHostModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Found CONFIGURATION_TOKEN
    in ConfigHostModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Resolving dependency CONFIGURATION(1dc97cb2-cd12-467a-959f-c645dc9420f8) in the CONFIGURATION_LOADER provider -
    {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for CONFIGURATION(1dc97cb2-cd12-467a-959f-c645dc9420f8) in ConfigModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Found CONFIGURATION(1dc97cb2-cd12-467a-959f-c645dc9420f8) in ConfigModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for String in StatusModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for Object in StatusModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for String in InternalCoreModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for Object in InternalCoreModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Resolving dependency AppService in the AppController provider - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Looking for AppService in
    AppModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InjectorLogger] Found AppService in AppModule - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InstanceLoader] StatusModule dependencies initialized - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InstanceLoader] ConfigHostModule dependencies initialized - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InstanceLoader] AppModule dependencies initialized - {}
    [NestWinston] Info 6.12.2021, 08:16:23 [InstanceLoader] ConfigModule dependencies initialized - {}

---- Here it gets stuck ^^ ----

@Meywether
Copy link
Author

Meywether commented Dec 6, 2021

Some experiments later I found a possible explaination for the not starting MS but it gets me to another problem:
Downgrading Redis to 3.1.2 with nest 8 apps let it work again! But both on redis 4 -> MS not working so I think that this is a possible redis 6.2 issue in connection with redis 4.0 package. Maybe related: #8710 (comment)

BUT If you want to trigger the status endpoint -> its throws me an 500 because suddenly my injected config service in status.controller ins the ms1 repo is suddenly undefined:

image

Can you maybe tell me why ? ^^

@kamilmysliwiec
Copy link
Member

#8710

@nestjs nestjs locked and limited conversation to collaborators Dec 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue has not been looked into type: bug 😭
Projects
None yet
Development

No branches or pull requests

4 participants