Throwing HealthCheckError in synchronous HealthIndicatorFunction does not work properly
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Current behavior
There is an issue with non-async health indicator functions due to the following:
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
@Get()
@HealthCheck()
async check() {
const result = await this.health.check([
() => throw new HealthCheckError('error', {}), // if changed to `async () => `, it works
])
}
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?
- macOS
- Windows
- Linux
Other
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Custom health indicator fail does not affect main status #1284
The idea behind it is that Terminus does not accidentally display an error message which might expose confidential information -- therefore we ...
Read more >Health checks (Terminus) - A progressive Node.js framework
A health indicator executes a check of a service, whether it is in a healthy or unhealthy state. A health check is positive...
Read more >ElasticSearch health check failed every time when spring boot ...
The problem is that the Elasticsearch Health check failed almost every time when Spring boot started from my local machine as the following ......
Read more >Troubleshoot failing health checks for Application Load ... - AWS
The targets registered to my Application Load Balancer aren't healthy. How do I find out why my targets are failing health checks?
Read more >An Overview of Health Check Patterns - DZone
No problem! At least your implementation is not misleading. But can we configure at least something useful for these services as well? Restarts....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Released with 9.1.4 🎉
@andreialecu Alright makes sense to me! Let’s go forward with your PR then 😃