Test #17

Merged
admin merged 127 commits from test into main 2026-09-28 16:00:14 +08:00
Showing only changes of commit f5e53db24f - Show all commits
+3 -3
View File
@@ -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,