fix(ql3): tolerate provider readiness convergence

This commit is contained in:
whyour
2026-08-25 03:30:34 +08:00
parent 931f9eee38
commit 2eb8b29e51
2 changed files with 17 additions and 3 deletions
@@ -1109,7 +1109,8 @@ async function retryProviderEvidence(read, pause = undefined) {
assert.equal(typeof read, 'function');
assert.ok(pause === undefined || typeof pause === 'function');
let lastError;
for (let attempt = 1; attempt <= 3; attempt += 1) {
const maxAttempts = 8;
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
try {
return await read();
} catch (error) {
@@ -1118,12 +1119,12 @@ async function retryProviderEvidence(read, pause = undefined) {
!/\b(?:ECONNREFUSED|ECONNRESET|ETIMEDOUT|TIMEOUT)\b/.test(
error instanceof Error ? error.message : String(error),
) ||
attempt === 3
attempt === maxAttempts
) {
throw error;
}
await (
pause ?? (() => new Promise((resolve) => setTimeout(resolve, 500)))
pause ?? (() => new Promise((resolve) => setTimeout(resolve, 1_000)))
)();
}
}
@@ -390,6 +390,19 @@ test('retries only bounded transient provider evidence failures', async () => {
),
/invalid evidence schema/,
);
attempts = 0;
await assert.rejects(
retryProviderEvidence(
async () => {
attempts += 1;
throw new Error('{"code":"ECONNREFUSED"}');
},
async () => {},
),
/ECONNREFUSED/,
);
assert.equal(attempts, 8);
});
test('provider fixture logs only generation and authorization decision', () => {