fix: address code review feedback for execution protection layer
- Remove hardcoded '90+ processes' in cancel message (use generic wording) - Extract LOCK_RELEASE_DELAY_MS constant in atomic-executor.js - Use array destructuring in watchdog for-of loop - Use role-based reference in checkpoint escalation message - Ensure next() is called in blockCancellation when not intercepting Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/6ee737eb-684b-44b8-aeaa-f73eb7c6f9c2
This commit is contained in:
parent
e0880deb46
commit
ade9c8dfc3
|
|
@ -64,7 +64,7 @@ router.post('/:executionId/cancel', function(_req, res) {
|
|||
error: true,
|
||||
code: 'CANCEL_FORBIDDEN',
|
||||
reply: '🔒 执行中的操作不可取消。\n\n' +
|
||||
'系统已开始执行,90+ 个自动化流程正在联动。' +
|
||||
'系统已开始执行,多个自动化流程正在联动。' +
|
||||
'中途中断会导致数据不一致和级联故障。\n\n' +
|
||||
'请等待执行完成。如果结果不理想,你可以说:\n' +
|
||||
'「前面的我没想好,我们重新来」\n' +
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ var executionLock = require('../middleware/execution-lock');
|
|||
var checkpoint = require('./checkpoint');
|
||||
var CheckpointManager = checkpoint.CheckpointManager;
|
||||
|
||||
// 锁释放延迟(给前端时间拉取最终状态)
|
||||
var LOCK_RELEASE_DELAY_MS = 10000;
|
||||
|
||||
/**
|
||||
* 原子执行器
|
||||
* @param {string} devId - 开发者编号
|
||||
|
|
@ -109,7 +112,7 @@ AtomicExecutor.prototype.execute = async function(operationName, fn) {
|
|||
lock.result = result;
|
||||
|
||||
// 延迟释放锁(给前端时间拉取最终状态)
|
||||
setTimeout(function() { executionLock.releaseLock(devId); }, 10000);
|
||||
setTimeout(function() { executionLock.releaseLock(devId); }, LOCK_RELEASE_DELAY_MS);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
|
@ -142,7 +145,7 @@ AtomicExecutor.prototype.execute = async function(operationName, fn) {
|
|||
lock.state = 'failed';
|
||||
lock.error = { message: e.message };
|
||||
|
||||
setTimeout(function() { executionLock.releaseLock(devId); }, 10000);
|
||||
setTimeout(function() { executionLock.releaseLock(devId); }, LOCK_RELEASE_DELAY_MS);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ CheckpointManager.prototype.escalateToAdmin = async function(checkpoint, error)
|
|||
rich_text: [{
|
||||
text: {
|
||||
content: '检查点 ' + checkpoint.id + ' (' + checkpoint.label +
|
||||
') 回滚失败: ' + error.message + '。需要冰朔人工介入。'
|
||||
') 回滚失败: ' + error.message + '。需要系统管理员人工介入。'
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@ function startWatchdog() {
|
|||
var activeLocks = executionLock.getActiveLocks();
|
||||
var now = Date.now();
|
||||
|
||||
for (var entry of activeLocks) {
|
||||
var devId = entry[0];
|
||||
var lock = entry[1];
|
||||
for (var [devId, lock] of activeLocks) {
|
||||
|
||||
if (lock.state !== 'running') continue;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue