Handle Connection Exceptions During Health Checks #786
+29
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The HttpGateway currently determines whether the SSR server is healthy by looking at the status of the response to the health check endpoint. If the server is not available at all though, there will be no response and a ConnectionException will occur. This causes the check-ssr command to fail quite aggressively due to an exception getting thrown without being caught.
Instead of letting that exception fall through, it seems reasonable to rescue the exception in the isHealthy method and say that it's not healthy if an exception occurred. Additionally, I also feel it's reasonable to not report said exception, but I don't have a strong opinion either way. The way that I noticed this was from seeing this exception after deploying while waiting for the SSR server to start up. In that scenario, I'm not concerned with the ConnectionException as the command is the failure indicator that is actually useful.
I had originally wrote the test implementation using
->pushFailedConnection(), but that was only added in Laravel 11. In order to keep the Laravel 10 support, I took the implementation of the exception from the PR that added it. laravel/framework#53485