From 09c3fc443b7802d3fd37c8e3bda3cd7594a295f4 Mon Sep 17 00:00:00 2001 From: hypercross Date: Tue, 28 Apr 2026 15:29:08 +0800 Subject: [PATCH] feat(core): wrap prompt middleware in try-finally block Ensure the prompt status is cleared even if the middleware chain throws an error. --- src/core/game-client.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/core/game-client.ts b/src/core/game-client.ts index ba7e71c..efae3f5 100644 --- a/src/core/game-client.ts +++ b/src/core/game-client.ts @@ -87,17 +87,20 @@ export abstract class BaseGameClient< } } - callback({ - hasPrompt: true, - player: ctx.player || "global", - def: ctx.def, - tryAnswer, - }); - await next(); - callback({ - hasPrompt: false, - player: ctx.player || "global", - }); + try { + callback({ + hasPrompt: true, + player: ctx.player || "global", + def: ctx.def, + tryAnswer, + }); + return await next(); + } finally { + callback({ + hasPrompt: false, + player: ctx.player || "global", + }); + } }); } selectStatus(callback: (status: ClientStatus) => void) {