-
Notifications
You must be signed in to change notification settings - Fork 48
Add logging for SSR render request failures (#63) #89
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
Conversation
When server-side rendering fails (e.g., SSR server unavailable or returns an error), Inertia silently falls back to client-side rendering. This made debugging SSR issues difficult since errors were swallowed without any trace. This change uses Python's logging module to log exceptions when SSR requests fail, providing visibility into SSR failures while maintaining the graceful fallback behavior. Fixes inertiajs#63
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.
Pull request overview
This PR adds logging for SSR (Server-Side Rendering) failures to improve debuggability while maintaining the existing graceful fallback behavior. Previously, when SSR requests failed, the application would silently fall back to client-side rendering without any indication of the failure.
Key changes:
- Introduces Python's logging module to log exceptions when SSR render requests fail
- Adds a test to verify that exceptions are properly logged during SSR failures
- Updates a comment to clarify that SSR errors result in both logging and fallback to client-side rendering
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| inertia/http.py | Adds logging module import, creates module-level logger, and logs exceptions when SSR requests fail |
| inertia/tests/test_ssr.py | Updates comment for clarity and adds new test to verify exception logging during SSR failures |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @patch("inertia.http.logger") | ||
| @patch("inertia.http.requests") | ||
| def test_it_logs_exception_on_ssr_failure(self, mock_requests, mock_logger): | ||
| error = ValueError("SSR rendering failed") | ||
|
|
||
| mock_response = Mock() | ||
| mock_response.raise_for_status.side_effect = error | ||
| mock_requests.post.return_value = mock_response | ||
|
|
||
| self.client.get("/props/") | ||
|
|
||
| mock_logger.exception.assert_called_once_with("SSR render request failed") |
Copilot
AI
Nov 25, 2025
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.
The test verifies that logging occurs but doesn't validate that the fallback behavior still works correctly. Consider asserting that the response contains the expected client-side rendering content (similar to line 75-77 in test_it_fallsback_on_failure) to ensure both logging and graceful degradation work together.
BrandonShar
left a comment
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.
Thanks @leeuwr we've been needing this!
When server-side rendering fails (e.g., SSR server unavailable or returns an error), Inertia silently falls back to client-side rendering. This made debugging SSR issues difficult since errors were swallowed without any trace.
This change uses Python's logging module to log exceptions when SSR requests fail, providing visibility into SSR failures while maintaining the graceful fallback behavior.
Fixes #63