Skip to content

HttpHealthIndicator.responseCheck does not work when status is >400 #1944

Closed
@BrunnerLivio

Description

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Given the following example:

this.http.responseCheck(
          'nestjs-docs',
          'http://localhost:3000/api/',
          (res) => {
            return res.status === 403;
          },
        ),

It will return the following result

{
    "status": "error",
    "info": {},
    "error": {
        "nestjs-docs": {
            "status": "down",
            "message": "Request failed with status code 403",
            "statusCode": 403,
            "statusText": "Forbidden"
        }
    },
    "details": {
        "nestjs-docs": {
            "status": "down",
            "message": "Request failed with status code 403",
            "statusCode": 403,
            "statusText": "Forbidden"
        }
    }
}

Even if the request itself to localhost:3000/api returns 403

Minimum reproduction code

this.http.responseCheck(
          'nestjs-docs',
          'http://localhost:3000/api/',
          (res) => {
            return res.status === 403;
          },
        ),

Steps to reproduce

No response

Expected behavior

It should at least handle the third paramter callback

Package version

9.0.0

NestJS version

No response

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions