66 active_effect ,
77 active_reaction ,
88 component_context ,
9+ handle_error ,
910 set_active_effect ,
1011 set_active_reaction ,
1112 set_component_context
@@ -58,6 +59,7 @@ export function boundary(node, boundary_fn, props) {
5859 block ( ( ) => {
5960 var boundary = /** @type {Effect } */ ( active_effect ) ;
6061 var hydrate_open = hydrate_node ;
62+ var is_rendering_failed = false ;
6163
6264 // We re-use the effect's fn property to avoid allocation of an additional field
6365 boundary . fn = ( /** @type { Error }} */ error ) => {
@@ -72,9 +74,10 @@ export function boundary(node, boundary_fn, props) {
7274 set_hydrate_node ( remove_nodes ( ) ) ;
7375 }
7476
75- // If we have nothing to capture the error then rethrow the error
76- // for another boundary to handle
77- if ( ! onerror && ! failed_snippet ) {
77+ // If we have nothing to capture the error then re-throw the error
78+ // for another boundary to handle, additionaly, if we're rendering
79+ // the fallback and that too fails, then re-throw the error
80+ if ( ( ! onerror && ! failed_snippet ) || is_rendering_failed ) {
7881 throw error ;
7982 }
8083
@@ -85,6 +88,7 @@ export function boundary(node, boundary_fn, props) {
8588 }
8689 with_boundary ( boundary , ( ) => {
8790 boundary_effect = null ;
91+ is_rendering_failed = false ;
8892 boundary_effect = branch ( ( ) => boundary_fn ( anchor ) ) ;
8993 } ) ;
9094 } ;
@@ -100,13 +104,19 @@ export function boundary(node, boundary_fn, props) {
100104 queue_micro_task ( ( ) => {
101105 with_boundary ( boundary , ( ) => {
102106 boundary_effect = null ;
103- boundary_effect = branch ( ( ) =>
104- failed_snippet (
105- anchor ,
106- ( ) => error ,
107- ( ) => reset
108- )
109- ) ;
107+ is_rendering_failed = true ;
108+ try {
109+ boundary_effect = branch ( ( ) => {
110+ failed_snippet (
111+ anchor ,
112+ ( ) => error ,
113+ ( ) => reset
114+ ) ;
115+ } ) ;
116+ } catch ( error ) {
117+ handle_error ( /** @type {Error } */ ( error ) , boundary , boundary . ctx ) ;
118+ }
119+ is_rendering_failed = false ;
110120 } ) ;
111121 } ) ;
112122 }
0 commit comments