Skip to content

Commit

Permalink
Merge pull request #85 from obgnail/dev
Browse files Browse the repository at this point in the history
update utils: 添加超时防御机制
  • Loading branch information
obgnail authored Aug 15, 2023
2 parents b0f2e0e + cfc54f2 commit 911c10c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plugin/global/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,18 @@
const detectorContainer = {}

const decorate = (until, obj, func, before, after, changeResult = false) => {
const start = new Date().getTime();
const uuid = Math.random();
detectorContainer[uuid] = setInterval(() => {
if (new Date().getTime() - start > 10000) {
console.log("decorate timeout!", until, obj, func, before, after, changeResult);
clearInterval(detectorContainer[uuid]);
delete detectorContainer[uuid];
return;
}

if (!until()) return;
clearInterval(detectorContainer[uuid]);

const decorator = (original, before, after) => {
return function () {
if (before) {
Expand Down

0 comments on commit 911c10c

Please sign in to comment.