fix: 强化工作流与插件运行状态处理
- 显式传播工作流缓存故障并补充仓储测试 - 防止状态轮询重入和过期响应,规范执行记录无权限响应
This commit is contained in:
@@ -44,7 +44,10 @@ const pollingNodes = ref<any[]>([]);
|
||||
const executeId = ref('');
|
||||
const pollingData = ref<any>({ nodes: {} });
|
||||
const initSignal = ref(false);
|
||||
const pollingTimer = ref<null | ReturnType<typeof setInterval>>(null);
|
||||
const POLLING_INTERVAL_MS = 1000;
|
||||
const pollingTimer = ref<null | ReturnType<typeof setTimeout>>(null);
|
||||
let pollingActive = false;
|
||||
let pollingGeneration = 0;
|
||||
const activeIndex = ref('1');
|
||||
const dialogContentKey = ref(0);
|
||||
const dialogPreparing = ref(false);
|
||||
@@ -237,42 +240,55 @@ function handleWorkflowSubmit(runParams: any) {
|
||||
|
||||
function startPolling(nextExecuteId: string) {
|
||||
stopPolling();
|
||||
pollingTimer.value = setInterval(() => {
|
||||
executePolling(nextExecuteId);
|
||||
}, 1000);
|
||||
pollingActive = true;
|
||||
pollingGeneration += 1;
|
||||
schedulePolling(nextExecuteId, pollingGeneration);
|
||||
}
|
||||
|
||||
function schedulePolling(nextExecuteId: string, generation: number) {
|
||||
pollingTimer.value = setTimeout(() => {
|
||||
pollingTimer.value = null;
|
||||
void executePolling(nextExecuteId, generation);
|
||||
}, POLLING_INTERVAL_MS);
|
||||
}
|
||||
|
||||
function stopPolling() {
|
||||
pollingActive = false;
|
||||
pollingGeneration += 1;
|
||||
if (pollingTimer.value) {
|
||||
clearInterval(pollingTimer.value);
|
||||
clearTimeout(pollingTimer.value);
|
||||
pollingTimer.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
function executePolling(nextExecuteId: string) {
|
||||
api
|
||||
.post('/api/v1/pluginItem/testChainStatus', {
|
||||
async function executePolling(nextExecuteId: string, generation: number) {
|
||||
try {
|
||||
const res = await api.post('/api/v1/pluginItem/testChainStatus', {
|
||||
executeId: nextExecuteId,
|
||||
nodes: pollingNodes.value,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.errorCode !== 0) {
|
||||
return;
|
||||
}
|
||||
const nextData = {
|
||||
...res.data,
|
||||
nodes: res.data?.nodes || {},
|
||||
};
|
||||
pollingData.value = nextData;
|
||||
runResultResponse.value = nextData;
|
||||
if (nextData.status !== 1) {
|
||||
stopPolling();
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
stopPolling();
|
||||
runResultResponse.value = buildErrorResult(error);
|
||||
});
|
||||
if (!pollingActive || generation !== pollingGeneration) return;
|
||||
if (res.errorCode !== 0) {
|
||||
stopPolling();
|
||||
return;
|
||||
}
|
||||
|
||||
const nextData = {
|
||||
...res.data,
|
||||
nodes: res.data?.nodes || {},
|
||||
};
|
||||
pollingData.value = nextData;
|
||||
runResultResponse.value = nextData;
|
||||
if (nextData.status !== 1) {
|
||||
stopPolling();
|
||||
return;
|
||||
}
|
||||
schedulePolling(nextExecuteId, generation);
|
||||
} catch (error) {
|
||||
if (!pollingActive || generation !== pollingGeneration) return;
|
||||
stopPolling();
|
||||
runResultResponse.value = buildErrorResult(error);
|
||||
}
|
||||
}
|
||||
|
||||
function resumeChain(payload: any) {
|
||||
|
||||
Reference in New Issue
Block a user