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', () => {
844844 await nextTick ( )
845845 expect ( calls ) . toEqual ( [ 'cb2' , 'cb1' ] )
846846 } )
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+ } )
847855} )
Original file line number Diff line number Diff line change @@ -119,7 +119,10 @@ export function queueJob(job: SchedulerJob): void {
119119
120120function queueFlush ( ) {
121121 if ( ! currentFlushPromise ) {
122- currentFlushPromise = resolvedPromise . then ( flushJobs )
122+ currentFlushPromise = resolvedPromise . then ( flushJobs ) . catch ( e => {
123+ currentFlushPromise = null
124+ throw e
125+ } )
123126 }
124127}
125128
@@ -201,8 +204,13 @@ export function flushPostFlushCbs(seen?: CountMap): void {
201204 if ( cb . flags ! & SchedulerJobFlags . ALLOW_RECURSE ) {
202205 cb . flags ! &= ~ SchedulerJobFlags . QUEUED
203206 }
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+ }
206214 }
207215 activePostFlushCbs = null
208216 postFlushIndex = 0
You can’t perform that action at this time.
0 commit comments