await nextTick()
expect(calls).toEqual(['cb2', 'cb1'])
})
+
+ test('error in postFlush cb should not cause nextTick to stuck in rejected state forever', async () => {
+ queuePostFlushCb(() => {
+ throw 'err'
+ })
+ await expect(nextTick).rejects.toThrow('err')
+ await expect(nextTick()).resolves.toBeUndefined()
+ })
})
function queueFlush() {
if (!currentFlushPromise) {
- currentFlushPromise = resolvedPromise.then(flushJobs)
+ currentFlushPromise = resolvedPromise.then(flushJobs).catch(e => {
+ currentFlushPromise = null
+ throw e
+ })
}
}
if (cb.flags! & SchedulerJobFlags.ALLOW_RECURSE) {
cb.flags! &= ~SchedulerJobFlags.QUEUED
}
- if (!(cb.flags! & SchedulerJobFlags.DISPOSED)) cb()
- cb.flags! &= ~SchedulerJobFlags.QUEUED
+ if (!(cb.flags! & SchedulerJobFlags.DISPOSED)) {
+ try {
+ cb()
+ } finally {
+ cb.flags! &= ~SchedulerJobFlags.QUEUED
+ }
+ }
}
activePostFlushCbs = null
postFlushIndex = 0