forked from Shared/esg
Add health check and retry logic and circuit breaker
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user