File tree Expand file tree Collapse file tree 5 files changed +54
-0
lines changed
src/internal/client/dom/blocks
tests/runtime-runes/samples/async-boundary-reset Expand file tree Collapse file tree 5 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: ensure batch exists when resetting a failed boundary
Original file line number Diff line number Diff line change @@ -297,6 +297,9 @@ export class Boundary {
297
297
e . svelte_boundary_reset_onerror ( ) ;
298
298
}
299
299
300
+ // If the failure happened while flushing effects, current_batch can be null
301
+ Batch . ensure ( ) ;
302
+
300
303
this . #pending_count = 0 ;
301
304
302
305
if ( this . #failed_effect !== null ) {
Original file line number Diff line number Diff line change
1
+ <script >
2
+ async function c (a ) {
3
+ await Promise .resolve ()
4
+ if (a) {
5
+ throw new Error (' error' );
6
+ } else {
7
+ return ' ok' ;
8
+ }
9
+ }
10
+
11
+ let a = $state ();
12
+ let b = $derived (await c (a));
13
+ </script >
14
+
15
+ <button onclick ={() => a = 1 }>{b }</button >
Original file line number Diff line number Diff line change
1
+ import { tick } from 'svelte' ;
2
+ import { test } from '../../test' ;
3
+
4
+ export default test ( {
5
+ async test ( { assert, target } ) {
6
+ await tick ( ) ;
7
+ let [ btn ] = target . querySelectorAll ( 'button' ) ;
8
+ btn . click ( ) ;
9
+ await tick ( ) ;
10
+
11
+ assert . htmlEqual ( target . innerHTML , '<button>reset</button>' ) ;
12
+
13
+ [ btn ] = target . querySelectorAll ( 'button' ) ;
14
+ btn . click ( ) ;
15
+ await tick ( ) ;
16
+
17
+ assert . htmlEqual ( target . innerHTML , '<button>ok</button>' ) ;
18
+ }
19
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import Test from ' ./Test.svelte' ;
3
+ </script >
4
+
5
+ <svelte:boundary >
6
+ <Test />
7
+
8
+ {#snippet pending ()}pending{/ snippet }
9
+ {#snippet failed (_ , reset )}
10
+ <button onclick ={reset }>reset</button >
11
+ {/ snippet }
12
+ </svelte:boundary >
You can’t perform that action at this time.
0 commit comments