-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Throwing HealthCheckError in synchronous HealthIndicatorFunction does not work properly #2083
Comments
Fixed in #2084 (/cc @BrunnerLivio) |
@andreialecu Curious; why would you want to run a synchronous health check? |
Because I have a specific case where I have a stream that sometimes randomly stops working, so I store a I had to dig through the Terminus code to see why this wasn't working right. If non async healthchecks should not be supported, the types could prevent a non-promise from being passed. But they specifically allow it: terminus/lib/health-indicator/health-indicator.ts Lines 8 to 10 in 8fdf979
So this seemed like a bug to me. PS: I'm currently working around it by passing an async function, but I thought someone else might run into this in the future, and it was worth fixing. |
@andreialecu Alright makes sense to me! Let's go forward with your PR then :) |
Released with 9.1.4 🎉 |
Is there an existing issue for this?
Current behavior
There is an issue with non-async health indicator functions due to the following:
terminus/lib/health-check/health-check-executor.service.ts
Line 63 in ea06b34
If an error is thrown synchronously, then the health check will reply with
{"statusCode":500,"message":"Internal server error"}
and the server will log the error.Minimum reproduction code
Steps to reproduce
No response
Expected behavior
It should not depend on the function being async.
Package version
9.1.3
NestJS version
not relevant
Node.js version
not relevant
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: