瀏覽代碼

fix error handle 死循环

Michael Wang 3 年之前
父節點
當前提交
23dc498196
共有 1 個文件被更改,包括 12 次插入7 次删除
  1. 12 7
      src/utils/monitors.ts

+ 12 - 7
src/utils/monitors.ts

@@ -54,13 +54,18 @@ window.addEventListener("unhandledrejection", function (event) {
 
   try {
     // 会造成死循环,logger.log 在网络异常的情况下,会有unhandledrejection
-    logger({
-      key: "unhandledrejection",
-      cnl: ["console", "local", "server"],
-      pgu: "AUTO",
-      dtl: event.reason,
-      ejn: JSON.stringify(event.reason),
-    });
+    setTimeout(
+      () =>
+        logger({
+          key: "unhandledrejection",
+          cnl: ["console", "local", "server"],
+          pgu: "AUTO",
+          stk: JSON.stringify(event),
+          dtl: event.reason,
+          ejn: JSON.stringify(event.reason),
+        }),
+      10 * 1000
+    );
     console.trace(event);
   } catch {
     logger({