Просмотр исходного кода

fix(scheduler): improve error handling in job flushing (#13587)

edison 9 месяцев назад
Родитель
Сommit
94b2ddc6f9
1 измененных файлов с 10 добавлено и 4 удалено
  1. 10 4
      packages/runtime-core/src/scheduler.ts

+ 10 - 4
packages/runtime-core/src/scheduler.ts

@@ -114,12 +114,18 @@ export function queueJob(job: SchedulerJob): void {
   }
 }
 
+const doFlushJobs = () => {
+  try {
+    flushJobs()
+  } catch (e) {
+    currentFlushPromise = null
+    throw e
+  }
+}
+
 function queueFlush() {
   if (!currentFlushPromise) {
-    currentFlushPromise = resolvedPromise.then(flushJobs).catch(e => {
-      currentFlushPromise = null
-      throw e
-    })
+    currentFlushPromise = resolvedPromise.then(doFlushJobs)
   }
 }