Added /healthz JSON response for heartbeat data. #1940#1984
Conversation
code-asher
left a comment
There was a problem hiding this comment.
This looks great! All my comments but one are just from the linter.
|
As for the new release, we should have one out this week. |
|
One interesting note is that if you use a browser then it requests the service worker which triggers a heart beat. But since this is going to be used by things that aren't browsers I think it should be fine. |
|
I'm so sorry about this! Deleted the dev branch was gonna switch this back to base on master but GitHub doesn't let you do that.... After you delete the PR base. 🤦 Please open a new PR with these changes! Once again, I'm so sorry! |
|
Nvm, got it! |
|
Figured out how to run the linter 😅 |
|
Everything looks great. Thank you for the contribution! |
| } | ||
|
|
||
| public async handleRequest(route: Route, request: http.IncomingMessage): Promise<HttpResponse> { | ||
| if (!this.authenticated(request)) { |
There was a problem hiding this comment.
Shouldn't this endpoint work regardless of whether or not we're authenticated? @code-asher
I added a JSON object with heartbeat information by passing the server's Heart to the new HealthHttpProvider. I wasn't quite sure what status code to use. I was considering
503for expired health checks but settled on200with state in the response content.I haven't written TypeScript before, perhaps a type for the
resultobject would be better?I made sure not to heartbeat for onRequest with the
/healthzroute.Closes #1940
Side note: when can we expect a new release? 3.4.1 is two months old and still has a broken heart 🙃 (zombie connections fixed by ebef18d)