fix(auction): harden lifecycle and durable bid storage

Serialize lifecycle changes and make cancellation, deadlines, and match side effects recoverable and idempotent.

Archive accepted bids durably, quarantine invalid payloads, and preserve compatibility with empty round IDs. Synchronize HTTP polling and socket state with scoped resync events.

Add cancellation cleanup index migration and regression coverage. Validated with 744 API tests, 65 Redis integration tests, and 28 Mongo integration tests.
This commit is contained in:
dahyeon committed 2026-11-09 23:24:11 +09:00
1 parent f2eec479d9
commit f649490cd2
55 files changed
+5374 -522

No files matched your search

@@ -0,0 +1,32 @@
import { AuctionLifecycleLock } from './auction-lifecycle-lock';
afterEach(() => jest.useRealTimers());
it('renews ownership and handles renewal/release failures without unhandled rejection', async () => {
jest.useFakeTimers();
const sendCommand = jest
.fn()
.mockRejectedValue(new Error('redis disconnected'));
const releaseTokenLock = jest
.fn()
.mockRejectedValue(new Error('release failed'));
const lock = new AuctionLifecycleLock({
acquireTokenLock: jest.fn().mockResolvedValue(true),
releaseTokenLock,
raw: () => ({ sendCommand }),
} as never);
const result = lock.run('match', async () => {
await jest.advanceTimersByTimeAsync(10000);
});
await expect(result).rejects.toThrow('redis disconnected');
expect(releaseTokenLock).toHaveBeenCalledTimes(1);
expect(jest.getTimerCount()).toBe(0);
});
it('preserves an operation result if only lock release fails', async () => {
const lock = new AuctionLifecycleLock({
acquireTokenLock: jest.fn().mockResolvedValue(true),
releaseTokenLock: jest.fn().mockRejectedValue(new Error('release failed')),
} as never);
await expect(lock.run('match', async () => 42)).resolves.toBe(42);
});