Skip to content

Commit fdda266

Browse files
Add error scenarios hub and test pages for streaming/RSC error paths
Add a comprehensive error scenarios hub page with: - Interactive config override controls for raise_on_prerender_error, throw_js_errors, and raise_non_shell_server_rendering_errors - Auto-submit dropdowns with config param forwarding to linked pages - Detailed documentation of 10 error scenarios (A-I + N) with config-aware behavior descriptions - Summary table showing expected behavior under each config combination Add test pages for each error scenario: - SSR shell error, async error, sync error, async prop error - RSC component error (via server router) - Stream error demo and stream shell error demo - Non-existing component pages (non-streaming, streaming, RSC) Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 8c5f4d4 commit fdda266

18 files changed

+1232
-0
lines changed

react_on_rails_pro/spec/dummy/app/controllers/pages_controller.rb

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class PagesController < ApplicationController # rubocop:disable Metrics/ClassLen
1919
session[:something_useful] = "REALLY USEFUL"
2020
end
2121

22+
before_action :apply_config_overrides
2223
before_action :data
2324

2425
before_action :initialize_shared_store, only: %i[client_side_hello_world_shared_store_controller
@@ -36,6 +37,57 @@ def cached_react_helmet
3637
render "/pages/pro/cached_react_helmet"
3738
end
3839

40+
def error_scenarios_hub
41+
render "/pages/error_scenarios_hub"
42+
end
43+
44+
def reset_error_configs
45+
ReactOnRails.configuration.raise_on_prerender_error = Rails.env.development?
46+
ReactOnRailsPro.configuration.throw_js_errors = false
47+
ReactOnRailsPro.configuration.raise_non_shell_server_rendering_errors = false
48+
redirect_to error_scenarios_hub_path
49+
end
50+
51+
def ssr_shell_error
52+
stream_view_containing_react_components(template: "/pages/ssr_shell_error")
53+
end
54+
55+
def ssr_async_error
56+
stream_view_containing_react_components(template: "/pages/ssr_async_error")
57+
end
58+
59+
def ssr_sync_error
60+
stream_view_containing_react_components(template: "/pages/ssr_sync_error")
61+
end
62+
63+
def ssr_async_prop_error
64+
stream_view_containing_react_components(template: "/pages/ssr_async_prop_error")
65+
end
66+
67+
def rsc_component_error
68+
stream_view_containing_react_components(template: "/pages/rsc_component_error")
69+
end
70+
71+
def non_existing_react_component
72+
render "/pages/non_existing_react_component"
73+
end
74+
75+
def non_existing_stream_react_component
76+
stream_view_containing_react_components(template: "/pages/non_existing_stream_react_component")
77+
end
78+
79+
def non_existing_rsc_payload
80+
stream_view_containing_react_components(template: "/pages/non_existing_rsc_payload")
81+
end
82+
83+
def stream_error_demo
84+
stream_view_containing_react_components(template: "/pages/stream_error_demo")
85+
end
86+
87+
def stream_shell_error_demo
88+
stream_view_containing_react_components(template: "/pages/stream_shell_error_demo")
89+
end
90+
3991
def stream_async_components
4092
stream_view_containing_react_components(template: "/pages/stream_async_components")
4193
end
@@ -126,6 +178,10 @@ def server_router
126178
stream_view_containing_react_components(template: "/pages/server_router")
127179
end
128180

181+
def server_side_hello_world_hooks
182+
stream_view_containing_react_components(template: "/pages/server_side_hello_world_hooks")
183+
end
184+
129185
def posts_page
130186
posts = fetch_posts.as_json
131187
posts.each do |post|
@@ -187,6 +243,22 @@ def calc_slow_app_props_server_render
187243
locals: { name: PROPS_NAME }, formats: :json)
188244
end
189245

246+
def apply_config_overrides
247+
bool = ActiveModel::Type::Boolean.new
248+
249+
if params[:raise_on_prerender_error].present?
250+
ReactOnRails.configuration.raise_on_prerender_error =
251+
bool.cast(params[:raise_on_prerender_error])
252+
end
253+
if params[:throw_js_errors].present?
254+
ReactOnRailsPro.configuration.throw_js_errors = bool.cast(params[:throw_js_errors])
255+
end
256+
return unless params[:raise_non_shell_server_rendering_errors].present?
257+
258+
ReactOnRailsPro.configuration.raise_non_shell_server_rendering_errors =
259+
bool.cast(params[:raise_non_shell_server_rendering_errors])
260+
end
261+
190262
def initialize_shared_store
191263
redux_store("SharedReduxStore", props: @app_props_server_render)
192264
end

react_on_rails_pro/spec/dummy/app/views/pages/error_scenarios_hub.html.erb

Lines changed: 1041 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<%= react_component("NonExistentComponent", props: {}, prerender: true, trace: true,
2+
auto_load_bundle: false, id: "non-existent-react-component-0") %>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= rsc_payload_react_component("NonExistentComponent", props: {}, auto_load_bundle: false) %>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<%= stream_react_component("NonExistentComponent", props: {}, prerender: true, trace: true,
2+
auto_load_bundle: false, id: "non-existent-stream-react-component-0") %>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<%= stream_react_component(
2+
"DeterministicRSCErrorComponent",
3+
props: {},
4+
prerender: true,
5+
trace: true,
6+
id: "DeterministicRSCErrorComponent-error-scenario-0",
7+
) %>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<%= stream_react_component(
2+
"StreamErrorDemo",
3+
props: {},
4+
trace: true,
5+
id: "StreamErrorDemo-error-scenario-0",
6+
) %>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<%= stream_react_component(
2+
"AsyncComponentsTreeForTesting",
3+
props: @app_props_server_render.merge(throwAsyncError: true),
4+
trace: true,
5+
id: "AsyncComponentsTreeForTesting-async-prop-error-0",
6+
) %>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<%= stream_react_component(
2+
"StreamShellErrorDemo",
3+
props: {},
4+
trace: true,
5+
id: "StreamShellErrorDemo-error-scenario-0",
6+
) %>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<%= stream_react_component(
2+
"AsyncComponentsTreeForTesting",
3+
props: @app_props_server_render.merge(throwSyncError: true),
4+
trace: true,
5+
id: "AsyncComponentsTreeForTesting-sync-error-0",
6+
) %>

0 commit comments

Comments
 (0)