fix(system-agent): clear passive poll timer portably

This commit is contained in:
jesse-merhi
2026-08-12 01:32:50 +10:00
parent 2a22f61532
commit ecdf6b1c40
+4 -5
View File
@@ -229,16 +229,15 @@ export class SystemAgentChatEngine {
return reply;
});
this.turnQueue = observation.catch(() => undefined);
let timer: ReturnType<typeof setTimeout> | undefined;
let cancelTimer: (() => void) | undefined;
const outcome = await Promise.race([
observation.then((reply) => ({ reply })),
new Promise<undefined>((resolve) => {
timer = setTimeout(resolve, 0);
const timer = setTimeout(resolve, 0);
cancelTimer = () => clearTimeout(timer);
}),
]);
if (timer) {
clearTimeout(timer);
}
cancelTimer?.();
if (outcome) {
if (
outcome.reply.text &&