mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-20 16:07:11 +08:00
fix(ql3): tolerate provider readiness convergence
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user