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

推荐订阅源

I
InfoQ
G
Google Developers Blog
Engineering at Meta
Engineering at Meta
月光博客
月光博客
博客园 - 聂微东
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
F
Fortinet All Blogs
H
Help Net Security
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
L
LangChain Blog
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium

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: parse discord gateway timeouts strictly · openclaw/o...
steipete · 2026-05-29 · via Recent Commits to openclaw:main

File tree

  • extensions/discord/src/monitor

Original file line numberDiff line numberDiff line change

@@ -1,7 +1,32 @@

11

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

2-

import { fetchDiscordGatewayInfo, resolveGatewayInfoWithFallback } from "./gateway-metadata.js";

2+

import {

3+

fetchDiscordGatewayInfo,

4+

resolveDiscordGatewayInfoTimeoutMs,

5+

resolveGatewayInfoWithFallback,

6+

} from "./gateway-metadata.js";

37
48

describe("Discord gateway metadata", () => {

9+

it("resolves gateway info timeouts from strict integer config and env values", () => {

10+

expect(resolveDiscordGatewayInfoTimeoutMs({ configuredTimeoutMs: 45_000 })).toBe(45_000);

11+

expect(

12+

resolveDiscordGatewayInfoTimeoutMs({

13+

env: { OPENCLAW_DISCORD_GATEWAY_INFO_TIMEOUT_MS: "90000" },

14+

}),

15+

).toBe(90_000);

16+

expect(resolveDiscordGatewayInfoTimeoutMs({ configuredTimeoutMs: 150_000 })).toBe(120_000);

17+

expect(

18+

resolveDiscordGatewayInfoTimeoutMs({

19+

configuredTimeoutMs: 1.5,

20+

env: { OPENCLAW_DISCORD_GATEWAY_INFO_TIMEOUT_MS: "0x1000" },

21+

}),

22+

).toBe(30_000);

23+

expect(

24+

resolveDiscordGatewayInfoTimeoutMs({

25+

env: { OPENCLAW_DISCORD_GATEWAY_INFO_TIMEOUT_MS: "1e3" },

26+

}),

27+

).toBe(30_000);

28+

});

29+
530

it("falls back on Cloudflare HTML rate limits without logging raw HTML", async () => {

631

const error = await fetchDiscordGatewayInfo({

732

token: "test",

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,6 @@

11

import type { APIGatewayBotInfo } from "discord-api-types/v10";

22

import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";

3+

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

34

import { captureHttpExchange } from "openclaw/plugin-sdk/proxy-capture";

45

import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";

56

import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";

@@ -64,12 +65,11 @@ async function materializeGuardedResponse(response: Response): Promise<Response>

6465

}

6566
6667

function normalizeGatewayInfoTimeoutMs(value: unknown): number | undefined {

67-

const numeric =

68-

typeof value === "number" ? value : typeof value === "string" ? Number(value) : Number.NaN;

69-

if (!Number.isFinite(numeric) || numeric <= 0) {

68+

const numeric = parseStrictPositiveInteger(value);

69+

if (numeric === undefined) {

7070

return undefined;

7171

}

72-

return Math.min(Math.floor(numeric), MAX_DISCORD_GATEWAY_INFO_TIMEOUT_MS);

72+

return Math.min(numeric, MAX_DISCORD_GATEWAY_INFO_TIMEOUT_MS);

7373

}

7474
7575

export function resolveDiscordGatewayInfoTimeoutMs(params?: {

Original file line numberDiff line numberDiff line change

@@ -233,6 +233,20 @@ describe("runDiscordGatewayLifecycle", () => {

233233

expect(resolveDiscordGatewayRuntimeReadyTimeoutMs({ env: {} })).toBe(30_000);

234234

});

235235
236+

it("ignores non-integer gateway READY timeout values", () => {

237+

expect(

238+

resolveDiscordGatewayReadyTimeoutMs({

239+

configuredTimeoutMs: 1.5,

240+

env: { OPENCLAW_DISCORD_READY_TIMEOUT_MS: "0x1000" },

241+

}),

242+

).toBe(15_000);

243+

expect(

244+

resolveDiscordGatewayRuntimeReadyTimeoutMs({

245+

env: { OPENCLAW_DISCORD_RUNTIME_READY_TIMEOUT_MS: "1e3" },

246+

}),

247+

).toBe(30_000);

248+

});

249+
236250

it("cleans up thread bindings when gateway wait fails before READY", async () => {

237251

waitForDiscordGatewayStopMock.mockRejectedValueOnce(new Error("startup failed"));

238252

const { lifecycleParams, threadStop, gatewaySupervisor } = createLifecycleHarness();

Original file line numberDiff line numberDiff line change

@@ -2,6 +2,7 @@ import {

22

createConnectedChannelStatusPatch,

33

createTransportActivityStatusPatch,

44

} from "openclaw/plugin-sdk/gateway-runtime";

5+

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

56

import { danger } from "openclaw/plugin-sdk/runtime-env";

67

import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";

78

import { attachDiscordGatewayLogging } from "../gateway-logging.js";

@@ -33,12 +34,11 @@ const DISCORD_GATEWAY_TRANSPORT_ACTIVITY_STATUS_MIN_INTERVAL_MS = 30_000;

3334

type GatewayReadyWaitResult = "ready" | "stopped" | "timeout";

3435
3536

function normalizeGatewayReadyTimeoutMs(value: unknown): number | undefined {

36-

const numeric =

37-

typeof value === "number" ? value : typeof value === "string" ? Number(value) : Number.NaN;

38-

if (!Number.isFinite(numeric) || numeric <= 0) {

37+

const numeric = parseStrictPositiveInteger(value);

38+

if (numeric === undefined) {

3939

return undefined;

4040

}

41-

return Math.min(Math.floor(numeric), MAX_DISCORD_GATEWAY_READY_TIMEOUT_MS);

41+

return Math.min(numeric, MAX_DISCORD_GATEWAY_READY_TIMEOUT_MS);

4242

}

4343
4444

export function resolveDiscordGatewayReadyTimeoutMs(params?: {