Skip to content

Conversation

@leeuwr
Copy link

@leeuwr leeuwr commented Nov 25, 2025

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

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
Copy link

Copilot AI left a 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.

Comment on lines +79 to +90
@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")
Copy link

Copilot AI Nov 25, 2025

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add logger call when SSR rendering fails

1 participant