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<
} }
} }
callback({ try {
hasPrompt: true, callback({
player: ctx.player || "global", hasPrompt: true,
def: ctx.def, player: ctx.player || "global",
tryAnswer, def: ctx.def,
}); tryAnswer,
await next(); });
callback({ return await next();
hasPrompt: false, } finally {
player: ctx.player || "global", callback({
}); hasPrompt: false,
player: ctx.player || "global",
});
}
}); });
} }
selectStatus(callback: (status: ClientStatus) => void) { selectStatus(callback: (status: ClientStatus) => void) {