fix(queue): back off failed queued auto-sends
This commit is contained in:
@@ -29,6 +29,8 @@ mock.module('@/sync/session-ui-store', () => ({
|
||||
|
||||
import {
|
||||
buildQueuedAutoSendPayload,
|
||||
getQueuedAutoSendRetryDelayMs,
|
||||
isQueuedAutoSendBackedOff,
|
||||
sendQueuedAutoSendPayload,
|
||||
shouldDispatchQueuedAutoSend,
|
||||
} from './useQueuedMessageAutoSend';
|
||||
@@ -49,6 +51,25 @@ describe('shouldDispatchQueuedAutoSend', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('queued auto-send retry backoff', () => {
|
||||
test('delay grows exponentially and is capped', () => {
|
||||
expect(getQueuedAutoSendRetryDelayMs(1)).toBe(2000);
|
||||
expect(getQueuedAutoSendRetryDelayMs(2)).toBe(4000);
|
||||
expect(getQueuedAutoSendRetryDelayMs(3)).toBe(8000);
|
||||
expect(getQueuedAutoSendRetryDelayMs(10)).toBe(60000);
|
||||
expect(getQueuedAutoSendRetryDelayMs(100)).toBe(60000);
|
||||
});
|
||||
|
||||
test('backs off only the failed message within its window', () => {
|
||||
const failure = { messageId: 'queued-1', failures: 1, nextAttemptAt: 10_000 };
|
||||
|
||||
expect(isQueuedAutoSendBackedOff(failure, 'queued-1', 9_999)).toBe(true);
|
||||
expect(isQueuedAutoSendBackedOff(failure, 'queued-1', 10_000)).toBe(false);
|
||||
expect(isQueuedAutoSendBackedOff(failure, 'queued-2', 9_999)).toBe(false);
|
||||
expect(isQueuedAutoSendBackedOff(undefined, 'queued-1', 0)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildQueuedAutoSendPayload', () => {
|
||||
beforeEach(() => {
|
||||
visibleAgents = [];
|
||||
|
||||
Reference in New Issue
Block a user