mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 02:52:43 +00:00
fix(discord): unify reconnect watchdog and land #31025/#30530
Landed follow-up intent from contributor PR #31025 (@theotarr) and PR #30530 (@liuxiaopai-ai). Co-authored-by: theotarr <theotarr@users.noreply.github.com> Co-authored-by: liuxiaopai-ai <liuxiaopai-ai@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@ export async function waitForDiscordGatewayStop(params: {
|
||||
abortSignal?: AbortSignal;
|
||||
onGatewayError?: (err: unknown) => void;
|
||||
shouldStopOnError?: (err: unknown) => boolean;
|
||||
registerForceStop?: (forceStop: (err: unknown) => void) => void;
|
||||
}): Promise<void> {
|
||||
const { gateway, abortSignal, onGatewayError, shouldStopOnError } = params;
|
||||
const emitter = gateway?.emitter;
|
||||
@@ -57,6 +58,9 @@ export async function waitForDiscordGatewayStop(params: {
|
||||
finishReject(err);
|
||||
}
|
||||
};
|
||||
const onForceStop = (err: unknown) => {
|
||||
finishReject(err);
|
||||
};
|
||||
|
||||
if (abortSignal?.aborted) {
|
||||
onAbort();
|
||||
@@ -65,5 +69,6 @@ export async function waitForDiscordGatewayStop(params: {
|
||||
|
||||
abortSignal?.addEventListener("abort", onAbort, { once: true });
|
||||
emitter?.on("error", onGatewayErrorEvent);
|
||||
params.registerForceStop?.(onForceStop);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user