2
2
import { DEV } from 'esm-env' ;
3
3
import { is_promise } from '../../../shared/utils.js' ;
4
4
import { block , branch , pause_effect , resume_effect } from '../../reactivity/effects.js' ;
5
- import { internal_set , mutable_source , source } from '../../reactivity/sources.js' ;
5
+ import {
6
+ internal_set ,
7
+ mutable_source ,
8
+ remove_from_legacy_sources ,
9
+ source
10
+ } from '../../reactivity/sources.js' ;
6
11
import { flushSync , set_active_effect , set_active_reaction } from '../../runtime.js' ;
7
12
import {
8
13
hydrate_next ,
@@ -62,6 +67,11 @@ export function await_block(node, get_input, pending_fn, then_fn, catch_fn) {
62
67
var error_source = ( runes ? source : mutable_source ) ( undefined ) ;
63
68
var resolved = false ;
64
69
70
+ function clean_sources ( ) {
71
+ remove_from_legacy_sources ( input_source ) ;
72
+ remove_from_legacy_sources ( error_source ) ;
73
+ }
74
+
65
75
/**
66
76
* @param {PENDING | THEN | CATCH } state
67
77
* @param {boolean } restore
@@ -79,17 +89,29 @@ export function await_block(node, get_input, pending_fn, then_fn, catch_fn) {
79
89
try {
80
90
if ( state === PENDING && pending_fn ) {
81
91
if ( pending_effect ) resume_effect ( pending_effect ) ;
82
- else pending_effect = branch ( ( ) => pending_fn ( anchor ) ) ;
92
+ else
93
+ pending_effect = branch ( ( ) => {
94
+ pending_fn ( anchor ) ;
95
+ return clean_sources ;
96
+ } ) ;
83
97
}
84
98
85
99
if ( state === THEN && then_fn ) {
86
100
if ( then_effect ) resume_effect ( then_effect ) ;
87
- else then_effect = branch ( ( ) => then_fn ( anchor , input_source ) ) ;
101
+ else
102
+ then_effect = branch ( ( ) => {
103
+ then_fn ( anchor , input_source ) ;
104
+ return clean_sources ;
105
+ } ) ;
88
106
}
89
107
90
108
if ( state === CATCH && catch_fn ) {
91
109
if ( catch_effect ) resume_effect ( catch_effect ) ;
92
- else catch_effect = branch ( ( ) => catch_fn ( anchor , error_source ) ) ;
110
+ else
111
+ catch_effect = branch ( ( ) => {
112
+ catch_fn ( anchor , error_source ) ;
113
+ return clean_sources ;
114
+ } ) ;
93
115
}
94
116
95
117
if ( state !== PENDING && pending_effect ) {
0 commit comments