-
Notifications
You must be signed in to change notification settings - Fork 3
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
Throw error for unknown check types #213
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fab - thanks @alexmuller
8ec4858
to
609f0d2
Compare
if (!(check.type in healthchecks)) { | ||
throw new Error( | ||
`Attempted to create check '${check.name}' of type ${check.type} which does not exist` | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: instead of throwing on the first undefined check, this could collect all the undefined checks and throw an error for all of them. would prevent a user playing error whackamole
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: this would crash the app at startup right? while we'd hope that would be caught by users in local dev, there's still a chance it could creep through to review/staging apps. maybe a safer alternative would be to output a permanently-failing check for undefined checks?
@alexmuller is this still useful? |
This is probably a new major semver.
@andygout observed in Financial-Times/next-newsletter-signup#434 that when you pass in a check with type
text
the check just silently doesn't show up. That is apparently intentional (at least according to n-health) but I think it's silly behaviour. Thanks Andy!This change makes n-health throw an error whenever it's told to run a check with a type that it doesn't understand.
This PR might be easier to review commit-by-commit to see the test for the previous behaviour. You can add
?w=1
to the GitHub diff URL to hide whitespace changes.