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({
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) {