1
0
Эх сурвалжийг харах

fix: throw `net::ERR_BLOCKED_BY_CLIENT` error when executing workflow

Ahmad Kholid 3 жил өмнө
parent
commit
f627c7c543

+ 11 - 9
src/background/workflowEngine/engine.js

@@ -38,6 +38,8 @@ class WorkflowEngine {
       },
     };
 
+    this.logHistoryId = 0;
+
     let variables = {};
     let { globalData } = workflow;
 
@@ -170,15 +172,15 @@ class WorkflowEngine {
   }
 
   addLogHistory(detail) {
-    if (
-      !this.saveLog &&
-      (this.history.length >= 1001 || detail.name === 'blocks-group') &&
-      detail.type !== 'error'
-    )
-      return;
+    if (detail.name === 'blocks-group') return;
+
+    const isLimit = this.history.length >= 1001;
+    const notErrorLog = detail.type !== 'error';
+
+    if ((!this.saveLog || isLimit) && notErrorLog) return;
 
-    const historyId = nanoid();
-    detail.id = historyId;
+    this.logHistoryId += 1;
+    detail.id = this.logHistoryId;
 
     if (
       detail.replacedValue ||
@@ -188,7 +190,7 @@ class WorkflowEngine {
         JSON.stringify(this.referenceData)
       );
 
-      this.historyCtxData[historyId] = {
+      this.historyCtxData[this.logHistoryId] = {
         referenceData: {
           loopData,
           variables,

+ 7 - 1
src/background/workflowEngine/helper.js

@@ -38,8 +38,14 @@ export function attachDebugger(tabId, prevTab) {
 export function waitTabLoaded(tabId, ms = 10000) {
   return new Promise((resolve, reject) => {
     let timeout = null;
+    const excludeErrors = ['net::ERR_BLOCKED_BY_CLIENT', 'net::ERR_ABORTED'];
+
     const onErrorOccurred = (details) => {
-      if (details.tabId !== tabId || details.error.includes('ERR_ABORTED'))
+      if (
+        details.tabId !== tabId ||
+        details.frameId !== 0 ||
+        !excludeErrors.includes(details.error)
+      )
         return;
 
       browser.webNavigation.onErrorOccurred.removeListener(onErrorOccurred);

+ 1 - 2
src/background/workflowEngine/worker.js

@@ -1,6 +1,5 @@
 import { nanoid } from 'nanoid';
 import browser from 'webextension-polyfill';
-import cloneDeep from 'lodash.clonedeep';
 import { toCamelCase, sleep, objectHasKey, isObject } from '@/utils/helper';
 import { tasks } from '@/utils/shared';
 import referenceData from '@/utils/referenceData';
@@ -84,7 +83,7 @@ class Worker {
       if (index === 0) {
         this.executeBlock(this.engine.blocks[node], prevBlockData);
       } else {
-        const state = cloneDeep({
+        const state = structuredClone({
           windowId: this.windowId,
           loopList: this.loopList,
           activeTab: this.activeTab,