This commit is contained in:
2026-08-27 15:02:40 +08:00
parent c06b808354
commit 1a0122b648
5 changed files with 20 additions and 11 deletions
+3 -4
View File
@@ -47,12 +47,12 @@ export function shouldReconcileCompletion(error = {}) {
}
/**
* A retry keeps the original operationId while taking the latest server
* version/command facts. It must never mint a new idempotency identity.
* A retry keeps the original operationId and the exact accepted request facts.
* expectedTaskVersion participates in requestHash and must not be refreshed.
*/
export function refreshCompletionAttempt(previousAttempt = {}, latestFacts = {}) {
if (!previousAttempt.operationId) throw new Error('缺少原完成操作标识,不能安全重试')
const expectedTaskVersion = latestFacts.expectedTaskVersion ?? latestFacts.taskVersion ?? previousAttempt.expectedTaskVersion
const expectedTaskVersion = previousAttempt.expectedTaskVersion
if (expectedTaskVersion === null || expectedTaskVersion === undefined) throw new Error('缺少服务端最新任务版本,不能安全重试')
return {
...previousAttempt,
@@ -61,4 +61,3 @@ export function refreshCompletionAttempt(previousAttempt = {}, latestFacts = {})
expectedTaskVersion: Number(expectedTaskVersion)
}
}