惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
宝玉的分享
宝玉的分享
月光博客
月光博客
B
Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
N
Netflix TechBlog - Medium
博客园_首页
GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
A
About on SuperTechFans
Y
Y Combinator Blog
L
LangChain Blog
有赞技术团队
有赞技术团队
D
Docker
爱范儿
爱范儿
博客园 - 司徒正美
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Microsoft Security Blog
Microsoft Security Blog
D
DataBreaches.Net

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(discord): cap monitor helper timeouts · openclaw/open...
steipete · 2026-05-30 · via Recent Commits to openclaw:main

File tree

  • extensions/discord/src/monitor

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,44 @@

1+

import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime";

2+

import { afterEach, describe, expect, it, vi } from "vitest";

3+

import { raceWithTimeout, withAbortTimeout } from "./timeouts.js";

4+
5+

afterEach(() => {

6+

vi.useRealTimers();

7+

vi.restoreAllMocks();

8+

});

9+
10+

describe("discord monitor timeouts", () => {

11+

it("caps raceWithTimeout timers before arming the watchdog", async () => {

12+

const timeoutSpy = vi

13+

.spyOn(globalThis, "setTimeout")

14+

.mockReturnValue(1 as unknown as ReturnType<typeof setTimeout>);

15+

vi.spyOn(globalThis, "clearTimeout").mockImplementation(() => undefined);

16+
17+

await expect(

18+

raceWithTimeout({

19+

promise: Promise.resolve("ok"),

20+

timeoutMs: Number.MAX_SAFE_INTEGER,

21+

onTimeout: () => "timeout",

22+

}),

23+

).resolves.toBe("ok");

24+
25+

expect(timeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);

26+

});

27+
28+

it("caps withAbortTimeout timers before arming the watchdog", async () => {

29+

const timeoutSpy = vi

30+

.spyOn(globalThis, "setTimeout")

31+

.mockReturnValue(1 as unknown as ReturnType<typeof setTimeout>);

32+

vi.spyOn(globalThis, "clearTimeout").mockImplementation(() => undefined);

33+
34+

await expect(

35+

withAbortTimeout({

36+

timeoutMs: Number.MAX_SAFE_INTEGER,

37+

createTimeoutError: () => new Error("timed out"),

38+

run: async () => "ok",

39+

}),

40+

).resolves.toBe("ok");

41+
42+

expect(timeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);

43+

});

44+

});

Original file line numberDiff line numberDiff line change

@@ -1,3 +1,5 @@

1+

import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";

2+
13

// Compatibility constants for existing imports. Discord no longer enforces

24

// channel-owned listener or inbound run timeouts.

35

export const DISCORD_DEFAULT_LISTENER_TIMEOUT_MS = 120_000;

@@ -43,9 +45,10 @@ export async function raceWithTimeout<T, U>(params: {

4345

timeoutMs: number;

4446

onTimeout: () => U;

4547

}): Promise<T | U> {

48+

const timeoutMs = resolveTimerTimeoutMs(params.timeoutMs, 1);

4649

let timeoutTimer: ReturnType<typeof setTimeout> | undefined;

4750

const timeoutPromise = new Promise<U>((resolve) => {

48-

timeoutTimer = setTimeout(() => resolve(params.onTimeout()), Math.max(1, params.timeoutMs));

51+

timeoutTimer = setTimeout(() => resolve(params.onTimeout()), timeoutMs);

4952

timeoutTimer.unref?.();

5053

});

5154

try {

@@ -62,16 +65,14 @@ export async function withAbortTimeout<T>(params: {

6265

createTimeoutError: () => Error;

6366

run: (signal: AbortSignal) => Promise<T>;

6467

}): Promise<T> {

68+

const timeoutMs = resolveTimerTimeoutMs(params.timeoutMs, 1);

6569

const controller = new AbortController();

6670

let timeoutTimer: ReturnType<typeof setTimeout> | undefined;

6771

const timeoutPromise = new Promise<never>((_, reject) => {

68-

timeoutTimer = setTimeout(

69-

() => {

70-

controller.abort();

71-

reject(params.createTimeoutError());

72-

},

73-

Math.max(1, params.timeoutMs),

74-

);

72+

timeoutTimer = setTimeout(() => {

73+

controller.abort();

74+

reject(params.createTimeoutError());

75+

}, timeoutMs);

7576

timeoutTimer.unref?.();

7677

});

7778

try {