fix: improve graceful shutdown — stop loop, drain fights, clear all state
Shutdown now: stops background fight loop, waits up to 15s for active fights to drain (polling every 500ms), clears human + poll pending challenges, clears bet escrow. Added clearEscrow() to betting.ts and 5 tests verifying cleanup functions and correct shutdown order. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
4134a27ea6
commit
3c5c6c6b95
@@ -15,6 +15,7 @@ describe('graceful shutdown cleanup', () => {
|
|||||||
scoring: 'factual',
|
scoring: 'factual',
|
||||||
timeout_ms: 30000,
|
timeout_ms: 30000,
|
||||||
answers: ['answer'],
|
answers: ['answer'],
|
||||||
|
baseDamage: 10,
|
||||||
}, 1)
|
}, 1)
|
||||||
|
|
||||||
// Verify it exists (getPendingChallenge takes fightId, botId)
|
// Verify it exists (getPendingChallenge takes fightId, botId)
|
||||||
@@ -35,7 +36,7 @@ describe('graceful shutdown cleanup', () => {
|
|||||||
// Create a pending poll challenge
|
// Create a pending poll challenge
|
||||||
const promise = waitForPollResponse(
|
const promise = waitForPollResponse(
|
||||||
'fight2', 'bot2',
|
'fight2', 'bot2',
|
||||||
{ type: 'speed_blitz', label: 'Speed Blitz', prompt: 'test', scoring: 'factual', timeout_ms: 30000, answers: [] },
|
{ type: 'speed_blitz', label: 'Speed Blitz', prompt: 'test', scoring: 'factual', timeout_ms: 30000, answers: [], baseDamage: 10 },
|
||||||
1, { name: 'opp', wins: 0, losses: 0 }, 'arena', null,
|
1, { name: 'opp', wins: 0, losses: 0 }, 'arena', null,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user