test: retry transient phase3 PDA requests
This commit is contained in:
@@ -74,6 +74,7 @@ export function stableLoadedCartonMarks(items) {
|
||||
}
|
||||
|
||||
async function request(context, method, path, body, headers = {}) {
|
||||
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
||||
try {
|
||||
const response = await fetch(`${context.options.gateway}${path}`, {
|
||||
method,
|
||||
@@ -84,7 +85,11 @@ async function request(context, method, path, body, headers = {}) {
|
||||
try { payload = raw ? JSON.parse(raw) : null } catch { /* bounded raw evidence */ }
|
||||
return { method, path, http: response.status, body: payload, raw: payload === null ? raw.slice(0, 500) : null,
|
||||
requestId: payload?.requestId || response.headers.get('x-request-id'), traceId: payload?.traceId || response.headers.get('x-trace-id') }
|
||||
} catch (error) { return { method, path, http: 0, body: null, raw: String(error), requestId: null, traceId: null } }
|
||||
} catch (error) {
|
||||
if (attempt === 3) return { method, path, http: 0, body: null, raw: String(error), requestId: null, traceId: null }
|
||||
await new Promise((resolve) => setTimeout(resolve, 250 * attempt))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function uploadEvidence(context, taskId, warehouseId, evidenceType, expectedVersion, keySuffix,
|
||||
|
||||
Reference in New Issue
Block a user