From f5e53db24f3c2af2c81aba4878839da3fc0d26df Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Thu, 24 Sep 2026 03:41:12 +0800 Subject: [PATCH] test: retry client order submit transport failures --- scripts/admin-test-env-modules/orders.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/admin-test-env-modules/orders.mjs b/scripts/admin-test-env-modules/orders.mjs index dfb38bed2..dd2f7bc54 100644 --- a/scripts/admin-test-env-modules/orders.mjs +++ b/scripts/admin-test-env-modules/orders.mjs @@ -21,9 +21,9 @@ function records(value) { return Array.isArray(value?.records) ? value.records : function pageOk(value) { return Array.isArray(value?.records) && Number.isFinite(Number(value?.total)) } function success(response) { return Boolean(response) && response.http === 200 && String(response.body?.code) === '200' } function sleep(milliseconds) { return new Promise((resolve) => setTimeout(resolve, milliseconds)) } -async function requestTransportRetry(context, method, path, body, token) { +async function requestTransportRetry(context, method, path, body, token, extraHeaders = {}) { for (let attempt = 1; attempt <= 3; attempt += 1) { - const response = await request(context, method, path, body, token) + const response = await request(context, method, path, body, token, extraHeaders) if (response?.http !== 0 || attempt === 3) return response await sleep(500 * attempt) } @@ -667,7 +667,7 @@ export async function run(context) { orderPersistenceFacts(draftAfterConflict) === orderPersistenceFacts(draft), `orderId=${orderId}, status=${draftAfterConflict?.order?.status ?? 'missing'}`, CONTRACT_OPTIONS) - const submitResponse = await request(context, 'POST', `${clientDetailPath}/submit`, undefined, + const submitResponse = await requestTransportRetry(context, 'POST', `${clientDetailPath}/submit`, undefined, merchantToken, { 'Idempotency-Key': key(context, 'client-submit') }) context.apiSuccess(MODULE, 'Client 提交隔离订单', submitResponse, `orderId=${orderId}`) const submitReplayResponse = await request(context, 'POST', `${clientDetailPath}/submit`, undefined,