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',
|
||||
timeout_ms: 30000,
|
||||
answers: ['answer'],
|
||||
baseDamage: 10,
|
||||
}, 1)
|
||||
|
||||
// Verify it exists (getPendingChallenge takes fightId, botId)
|
||||
@@ -35,7 +36,7 @@ describe('graceful shutdown cleanup', () => {
|
||||
// Create a pending poll challenge
|
||||
const promise = waitForPollResponse(
|
||||
'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,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user