Skip to content

Conversation

@masenf
Copy link
Collaborator

@masenf masenf commented Oct 23, 2025

For configurable types of errors refresh once per configurable period in an attempt to automatically clear spurious issues when reloading.

For configurable types of errors refresh once per configurable period in an
attempt to automatically clear spurious issues when reloading.
@linear
Copy link

linear bot commented Oct 23, 2025

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 23, 2025

CodSpeed Performance Report

Merging #5922 will create unknown performance changes

Comparing masenf/magic-refreshing-error-boundary (b6089be) with main (e53b65d)

Summary

⚠️ No benchmarks were detected in both the base of the PR and the PR.
Please ensure that your benchmarks are correctly instrumented with CodSpeed.

Check out the benchmarks creation guide

⏩ 8 skipped1

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

Added automatic page reload functionality to handle_frontend_exception for configurable error patterns. When frontend errors match entries in auto_reload_on_errors (currently targeting "TypeError: Cannot read properties of null"), the page automatically reloads once per configurable cooldown period (10 seconds) to clear spurious issues.

Key changes:

  • Added auto_reload_on_errors ClassVar to configure which error messages trigger auto-reload
  • Added auto_reload_cooldown_time_ms ClassVar (10 seconds) to prevent reload loops
  • Modified handle_frontend_exception to yield an EventSpec that executes JavaScript to check sessionStorage and conditionally reload
  • Import Iterator from collections.abc and call_script from reflex.event

Minor recommendations:

  • Extract the sessionStorage key 'reflex_last_reloaded_on_error' into a constant
  • Add human-readable comment for the cooldown duration (10000ms = 10 seconds)
  • Update window.location.reload(true) to window.location.reload() as the boolean parameter is deprecated

Confidence Score: 4/5

  • This PR is safe to merge with minor style improvements recommended
  • The implementation is sound with proper cooldown logic to prevent reload loops. The changes are focused and well-documented. The three style comments are minor improvements (constant extraction, time duration comment, deprecated API usage) that don't affect functionality.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
reflex/state.py 4/5 Added auto-reload functionality for frontend exceptions with configurable error patterns and cooldown period. Minor style improvements recommended.

Sequence Diagram

sequenceDiagram
    participant Frontend
    participant FrontendEventExceptionState
    participant SessionStorage
    participant Browser
    
    Frontend->>FrontendEventExceptionState: handle_frontend_exception(info, component_stack)
    FrontendEventExceptionState->>FrontendEventExceptionState: Check if error matches auto_reload_on_errors
    alt Error matches and within cooldown
        FrontendEventExceptionState->>SessionStorage: Get 'reflex_last_reloaded_on_error'
        SessionStorage-->>FrontendEventExceptionState: Return last_reload timestamp
        FrontendEventExceptionState->>FrontendEventExceptionState: Check if (now - last_reload) > cooldown_time_ms
        alt Outside cooldown period
            FrontendEventExceptionState->>SessionStorage: Set 'reflex_last_reloaded_on_error' to now
            FrontendEventExceptionState->>Browser: Trigger window.location.reload()
            Browser->>Browser: Reload page
        end
    end
    FrontendEventExceptionState->>FrontendEventExceptionState: Call frontend_exception_handler(Exception(info))
Loading

1 file reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@adhami3310 adhami3310 merged commit 4ed8ed2 into main Oct 23, 2025
46 of 47 checks passed
@adhami3310 adhami3310 deleted the masenf/magic-refreshing-error-boundary branch October 23, 2025 20:09
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.

3 participants