Browse Source

fix: workers delete need wait detach debugger

siykt 1 năm trước cách đây
mục cha
commit
32febbb6d6
1 tập tin đã thay đổi với 6 bổ sung5 xóa
  1. 6 5
      src/workflowEngine/WorkflowEngine.js

+ 6 - 5
src/workflowEngine/WorkflowEngine.js

@@ -392,17 +392,18 @@ class WorkflowEngine {
     await browser.storage.local.set({ workflowQueue });
   }
 
-  destroyWorker(workerId) {
-    this.workers.delete(workerId);
-
-    if (this.workers.size === 0) {
+  async destroyWorker(workerId) {
+    // is last worker
+    if (this.workers.size === 1 && this.workers.has(workerId)) {
       this.addLogHistory({
         type: 'finish',
         name: 'finish',
       });
       this.dispatchEvent('finish');
-      this.destroy('success');
+      await this.destroy('success');
     }
+    // wait detach debugger
+    this.workers.delete(workerId);
   }
 
   async destroy(status, message, blockDetail) {