fix(feishu): clamp sequential queue timeouts

This commit is contained in:
Peter Steinberger
2026-05-30 19:19:26 -04:00
parent 7595d52e56
commit fab8d29d21
2 changed files with 25 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
/**
* Per-key serial task queue for Feishu inbound message handling.
*
@@ -65,16 +67,17 @@ async function boundedRun(
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
return task();
}
const resolvedTimeoutMs = resolveTimerTimeoutMs(timeoutMs, DEFAULT_TASK_TIMEOUT_MS);
let timeoutHandle: ReturnType<typeof setTimeout> | undefined;
const timeoutPromise = new Promise<void>((resolve) => {
timeoutHandle = setTimeout(() => {
try {
onTaskTimeout?.(key, timeoutMs);
onTaskTimeout?.(key, resolvedTimeoutMs);
} catch {
// Swallow logging errors so they cannot poison the queue chain.
}
resolve();
}, timeoutMs);
}, resolvedTimeoutMs);
});
try {
await Promise.race([task(), timeoutPromise]);