Skip to content

Commit 2a2b92a

Browse files
author
Taois
committed
fix: 修复两个重大问题
1. drpyS模块执行完毕后无法自动退出问题,受百度网盘错误的清理逻辑影响 2. 30秒安全超时执行机制函数异常,导致正常程序结束后无法结束进程问题
1 parent 8155931 commit 2a2b92a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

libs/drpyS.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,10 @@ export async function init(filePath, env = {}, refresh) {
416416
// ruleScript.runInContext(context);
417417
// const result = await ruleScript.runInContext(context);
418418
const executeWithTimeout = (script, context, timeout) => {
419+
let timer;
419420
return Promise.race([
420421
new Promise((_, reject) =>
421-
setTimeout(() => reject(new Error('Code execution timed out')), timeout)
422+
timer = setTimeout(() => reject(new Error('Code execution timed out')), timeout)
422423
),
423424
new Promise((resolve, reject) => {
424425
try {
@@ -434,7 +435,9 @@ export async function init(filePath, env = {}, refresh) {
434435
reject(error);
435436
}
436437
})
437-
]);
438+
]).finally(() => {
439+
if (timer) clearTimeout(timer);
440+
});
438441
};
439442
const result = await executeWithTimeout(ruleScript, context, 30000);
440443
// log('result:', result);

utils/pan/baidu.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class BaiduHandler {
4242
this.cleanupInterval = setInterval(() => {
4343
this.clearSaveDir();
4444
}, 2 * 60 * 60 * 1000);
45+
// 不阻止进程退出
46+
if (this.cleanupInterval.unref) {
47+
this.cleanupInterval.unref();
48+
}
4549
}
4650

4751
/**

0 commit comments

Comments
 (0)