feat(core): wrap prompt middleware in try-finally block

Ensure the prompt status is cleared even if the middleware chain
throws an error.
This commit is contained in:
hypercross 2026-04-28 15:29:08 +08:00
parent a0b2003c65
commit 09c3fc443b
1 changed files with 14 additions and 11 deletions

View File

@ -87,17 +87,20 @@ export abstract class BaseGameClient<
} }
} }
try {
callback({ callback({
hasPrompt: true, hasPrompt: true,
player: ctx.player || "global", player: ctx.player || "global",
def: ctx.def, def: ctx.def,
tryAnswer, tryAnswer,
}); });
await next(); return await next();
} finally {
callback({ callback({
hasPrompt: false, hasPrompt: false,
player: ctx.player || "global", player: ctx.player || "global",
}); });
}
}); });
} }
selectStatus(callback: (status: ClientStatus) => void) { selectStatus(callback: (status: ClientStatus) => void) {