Add health check and retry logic and circuit breaker

This commit is contained in:
SepehrYahyaee
2026-09-28 17:01:53 +03:30
parent 22371f4a03
commit 03fa5e0f20
67 changed files with 3101 additions and 410 deletions
+28
View File
@@ -42,6 +42,34 @@ describe('timeout / deadline resilience bugs', () => {
expect(Date.now() - started).toBeLessThan(250);
});
it('aborts the active operation when the attempt timeout wins', async () => {
let aborted = false;
await expect(
runWithProviderResilience(
(signal) =>
new Promise((resolve) => {
signal?.addEventListener('abort', () => {
aborted = true;
resolve('cancelled');
});
}),
{
providerName: 'PARSIAN',
maxAttempts: 1,
timeoutMs: 150,
context: {
requestId: 'req',
trackingCode: 'trk',
},
label: 'PARSIAN request',
},
),
).rejects.toMatchObject({ code: 'ETIMEDOUT' });
expect(aborted).toBe(true);
});
it('default inquiry deadline must exceed a single slow CentInsur SOAP (~30s)', () => {
// thirdPartyCar may need two SOAP calls over a proxy; 20s was killing successful ~28s responses
expect(INQUIRY_DEADLINE_MS).toBeGreaterThanOrEqual(60_000);