fix: clean up fight event listeners after completion (BUG-12)
Move fightEvents.cleanup(fightId) to finally block to ensure cleanup runs even if post-fight operations (bets, payouts) fail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
0f606cc991
commit
0f95cbf881
@@ -555,6 +555,7 @@ async function executeFightRounds(fightId: string, botA: BotRecord, botB: BotRec
|
||||
potSats: mode === 'ranked' ? 42 : 0,
|
||||
})
|
||||
|
||||
try {
|
||||
// Publish notable results to Nostr
|
||||
if (winnerId) {
|
||||
const winner = winnerId === botA.id ? botA : botB
|
||||
@@ -608,8 +609,9 @@ async function executeFightRounds(fightId: string, botA: BotRecord, botB: BotRec
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
fightEvents.cleanup(fightId)
|
||||
}
|
||||
}
|
||||
|
||||
export async function runFight(botAId: string, botBId: string, mode: 'free' | 'ranked' = 'free'): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user