nestjs / terminus

Terminus module for Nest framework (node.js) :robot:

Home Page:https://nestjs.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Microservice health indicator does not throw an error when RMQ connection is down

BrunnerLivio opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

In case the RMQ connection is down, the health indicator will be displayed as "down" but the health check is still healthy.

Minimum reproduction code

Given the following health check:

return this.health.check([
      () =>
        this.disk.checkStorage('disk', { path: '/', thresholdPercent: 0.5 }),
      () =>
        this.microservice.pingCheck('tcp', {
          transport: Transport.RMQ,
          options: {
            urls: ['amqp://localhost:5672'],
            queue: 'cats_queue',
            queueOptions: {
              durable: false,
            },
          },
        }),
    ]);

In case RMQ is down the health check will still be seen as healthy.

Steps to reproduce

No response

Expected behavior

It should be unhealthy

Package version

8.1.0

NestJS version

8.x.x

Node.js version

16.x.x

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Can be fixed by adding the following lines to the catch-clause of MicroserviceHealthIndicator.pingCheck.

throw new HealthCheckError(
                    err,
                    this.getStatus(key, false, { message: err }),
}

@BrunnerLivio Are you planning to implement this fix? If not let me know and I can put up a PR with your suggested change.