@@ -108,9 +108,8 @@ export function queueJob(job: SchedulerJob): void {
108
108
queue . splice ( findInsertionIndex ( jobId ) , 0 , job )
109
109
}
110
110
111
- if ( ! ( job . flags ! & SchedulerJobFlags . ALLOW_RECURSE ) ) {
112
- job . flags ! |= SchedulerJobFlags . QUEUED
113
- }
111
+ job . flags ! |= SchedulerJobFlags . QUEUED
112
+
114
113
queueFlush ( )
115
114
}
116
115
}
@@ -128,9 +127,7 @@ export function queuePostFlushCb(cb: SchedulerJobs): void {
128
127
activePostFlushCbs . splice ( postFlushIndex + 1 , 0 , cb )
129
128
} else if ( ! ( cb . flags ! & SchedulerJobFlags . QUEUED ) ) {
130
129
pendingPostFlushCbs . push ( cb )
131
- if ( ! ( cb . flags ! & SchedulerJobFlags . ALLOW_RECURSE ) ) {
132
- cb . flags ! |= SchedulerJobFlags . QUEUED
133
- }
130
+ cb . flags ! |= SchedulerJobFlags . QUEUED
134
131
}
135
132
} else {
136
133
// if cb is an array, it is a component lifecycle hook which can only be
@@ -161,6 +158,9 @@ export function flushPreFlushCbs(
161
158
}
162
159
queue . splice ( i , 1 )
163
160
i --
161
+ if ( cb . flags ! & SchedulerJobFlags . ALLOW_RECURSE ) {
162
+ cb . flags ! &= ~ SchedulerJobFlags . QUEUED
163
+ }
164
164
cb ( )
165
165
cb . flags ! &= ~ SchedulerJobFlags . QUEUED
166
166
}
@@ -194,6 +194,9 @@ export function flushPostFlushCbs(seen?: CountMap): void {
194
194
if ( __DEV__ && checkRecursiveUpdates ( seen ! , cb ) ) {
195
195
continue
196
196
}
197
+ if ( cb . flags ! & SchedulerJobFlags . ALLOW_RECURSE ) {
198
+ cb . flags ! &= ~ SchedulerJobFlags . QUEUED
199
+ }
197
200
if ( ! ( cb . flags ! & SchedulerJobFlags . DISPOSED ) ) cb ( )
198
201
cb . flags ! &= ~ SchedulerJobFlags . QUEUED
199
202
}
@@ -228,6 +231,9 @@ function flushJobs(seen?: CountMap) {
228
231
if ( __DEV__ && check ( job ) ) {
229
232
continue
230
233
}
234
+ if ( job . flags ! & SchedulerJobFlags . ALLOW_RECURSE ) {
235
+ job . flags ! &= ~ SchedulerJobFlags . QUEUED
236
+ }
231
237
callWithErrorHandling (
232
238
job ,
233
239
job . i ,
@@ -237,6 +243,14 @@ function flushJobs(seen?: CountMap) {
237
243
}
238
244
}
239
245
} finally {
246
+ // If there was an error we still need to clear the QUEUED flags
247
+ for ( ; flushIndex < queue . length ; flushIndex ++ ) {
248
+ const job = queue [ flushIndex ]
249
+ if ( job ) {
250
+ job . flags ! &= ~ SchedulerJobFlags . QUEUED
251
+ }
252
+ }
253
+
240
254
flushIndex = 0
241
255
queue . length = 0
242
256
0 commit comments