File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -844,4 +844,12 @@ describe('scheduler', () => {
844
844
await nextTick ( )
845
845
expect ( calls ) . toEqual ( [ 'cb2' , 'cb1' ] )
846
846
} )
847
+
848
+ test ( 'error in postFlush cb should not cause nextTick to stuck in rejected state forever' , async ( ) => {
849
+ queuePostFlushCb ( ( ) => {
850
+ throw 'err'
851
+ } )
852
+ await expect ( nextTick ) . rejects . toThrow ( 'err' )
853
+ await expect ( nextTick ( ) ) . resolves . toBeUndefined ( )
854
+ } )
847
855
} )
Original file line number Diff line number Diff line change @@ -119,7 +119,10 @@ export function queueJob(job: SchedulerJob): void {
119
119
120
120
function queueFlush ( ) {
121
121
if ( ! currentFlushPromise ) {
122
- currentFlushPromise = resolvedPromise . then ( flushJobs )
122
+ currentFlushPromise = resolvedPromise . then ( flushJobs ) . catch ( e => {
123
+ currentFlushPromise = null
124
+ throw e
125
+ } )
123
126
}
124
127
}
125
128
@@ -201,8 +204,13 @@ export function flushPostFlushCbs(seen?: CountMap): void {
201
204
if ( cb . flags ! & SchedulerJobFlags . ALLOW_RECURSE ) {
202
205
cb . flags ! &= ~ SchedulerJobFlags . QUEUED
203
206
}
204
- if ( ! ( cb . flags ! & SchedulerJobFlags . DISPOSED ) ) cb ( )
205
- cb . flags ! &= ~ SchedulerJobFlags . QUEUED
207
+ if ( ! ( cb . flags ! & SchedulerJobFlags . DISPOSED ) ) {
208
+ try {
209
+ cb ( )
210
+ } finally {
211
+ cb . flags ! &= ~ SchedulerJobFlags . QUEUED
212
+ }
213
+ }
206
214
}
207
215
activePostFlushCbs = null
208
216
postFlushIndex = 0
You can’t perform that action at this time.
0 commit comments