Skip to content

Commit eb6fa0d

Browse files
junsuwhysteipete
authored andcommitted
fix(googlechat): keep startAccount pending until abort to prevent restart loop
1 parent cb917b7 commit eb6fa0d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

extensions/googlechat/src/channel.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,20 @@ export const googlechatPlugin: ChannelPlugin<ResolvedGoogleChatAccount> = {
563563
webhookUrl: account.config.webhookUrl,
564564
statusSink: (patch) => ctx.setStatus({ accountId: account.accountId, ...patch }),
565565
});
566-
return () => {
567-
unregister?.();
568-
ctx.setStatus({
569-
accountId: account.accountId,
570-
running: false,
571-
lastStopAt: Date.now(),
572-
});
573-
};
566+
// Keep the promise pending until abort (webhook mode is passive).
567+
await new Promise<void>((resolve) => {
568+
if (ctx.abortSignal.aborted) {
569+
resolve();
570+
return;
571+
}
572+
ctx.abortSignal.addEventListener("abort", () => resolve(), { once: true });
573+
});
574+
unregister?.();
575+
ctx.setStatus({
576+
accountId: account.accountId,
577+
running: false,
578+
lastStopAt: Date.now(),
579+
});
574580
},
575581
},
576582
};

0 commit comments

Comments
 (0)