fix: 避免识别异常与支付锁泄漏
修复 ASR 取消后的孤立会话、OCR 表格重复及支付锁无法回收的问题,并补充回归测试。
This commit is contained in:
+6
-4
@@ -19,9 +19,11 @@ const payLocks = new Map();
|
||||
function withPayLock(key, fn) {
|
||||
const previous = payLocks.get(key) || Promise.resolve();
|
||||
const current = previous.then(fn, fn);
|
||||
payLocks.set(key, current.finally(() => {
|
||||
if (payLocks.get(key) === current) payLocks.delete(key);
|
||||
}));
|
||||
const tracked = current.then(
|
||||
() => { if (payLocks.get(key) === tracked) payLocks.delete(key); },
|
||||
() => { if (payLocks.get(key) === tracked) payLocks.delete(key); }
|
||||
);
|
||||
payLocks.set(key, tracked);
|
||||
return current;
|
||||
}
|
||||
|
||||
@@ -1242,4 +1244,4 @@ function startPaymentPatrol({ intervalMs = 10 * 60 * 1000 } = {}) {
|
||||
return patrolTimer;
|
||||
}
|
||||
|
||||
export { HandlerPayment, startPaymentPatrol, runPaymentPatrolOnce };
|
||||
export { HandlerPayment, startPaymentPatrol, runPaymentPatrolOnce, withPayLock, payLocks };
|
||||
|
||||
Reference in New Issue
Block a user