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

推荐订阅源

J
Java Code Geeks
腾讯CDC
博客园 - 聂微东
爱范儿
爱范儿
罗磊的独立博客
P
Proofpoint News Feed
博客园 - Franky
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
美团技术团队
MongoDB | Blog
MongoDB | Blog
WordPress大学
WordPress大学
A
About on SuperTechFans
I
InfoQ
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog

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: log fetch timeout aborts (#73692) · openclaw/opencla...
kevinslin · 2026-04-29 · via Recent Commits to openclaw:main

@@ -1,3 +1,16 @@

1+

import { createSubsystemLogger } from "../logging/subsystem.js";

2+3+

const log = createSubsystemLogger("fetch-timeout");

4+

const LOG_URL_MAX_CHARS = 500;

5+

const URL_SECRET_SUFFIX_PATTERN = /[?#]/;

6+7+

type TimeoutAbortSignalParams = {

8+

timeoutMs?: number;

9+

signal?: AbortSignal;

10+

operation?: string;

11+

url?: string;

12+

};

13+114

/**

215

* Relay abort without forwarding the Event argument as the abort reason.

316

* Using .bind() avoids closure scope capture (memory leak prevention).

@@ -11,7 +24,56 @@ export function bindAbortRelay(controller: AbortController): () => void {

1124

return relayAbort.bind(controller);

1225

}

132614-

export function buildTimeoutAbortSignal(params: { timeoutMs?: number; signal?: AbortSignal }): {

27+

function sanitizeTimeoutLogUrl(rawUrl: string | undefined): string | undefined {

28+

const trimmed = rawUrl?.trim();

29+

if (!trimmed) {

30+

return undefined;

31+

}

32+

try {

33+

const parsed = new URL(trimmed);

34+

parsed.username = "";

35+

parsed.password = "";

36+

parsed.search = "";

37+

parsed.hash = "";

38+

const value = parsed.toString();

39+

return value.length > LOG_URL_MAX_CHARS ? `${value.slice(0, LOG_URL_MAX_CHARS)}...` : value;

40+

} catch {

41+

const withoutQueryOrHash = trimmed.split(URL_SECRET_SUFFIX_PATTERN, 1)[0] ?? "";

42+

const cleaned = withoutQueryOrHash

43+

.replace(/[\r\n\u2028\u2029]+/g, " ")

44+

.replace(/\p{Cc}+/gu, " ")

45+

.replace(/\s+/g, " ")

46+

.trim();

47+

if (!cleaned) {

48+

return undefined;

49+

}

50+

return cleaned.length > LOG_URL_MAX_CHARS

51+

? `${cleaned.slice(0, LOG_URL_MAX_CHARS)}...`

52+

: cleaned;

53+

}

54+

}

55+56+

function abortDueToTimeout(

57+

controller: AbortController,

58+

timeoutMs: number,

59+

startedAtMs: number,

60+

operation?: string,

61+

url?: string,

62+

) {

63+

if (controller.signal.aborted) {

64+

return;

65+

}

66+

const sanitizedUrl = sanitizeTimeoutLogUrl(url);

67+

log.warn("fetch timeout reached; aborting operation", {

68+

timeoutMs,

69+

elapsedMs: Math.max(0, Date.now() - startedAtMs),

70+

...(operation ? { operation } : {}),

71+

...(sanitizedUrl ? { url: sanitizedUrl } : {}),

72+

});

73+

controller.abort();

74+

}

75+76+

export function buildTimeoutAbortSignal(params: TimeoutAbortSignalParams): {

1577

signal?: AbortSignal;

1678

cleanup: () => void;

1779

} {

@@ -24,7 +86,16 @@ export function buildTimeoutAbortSignal(params: { timeoutMs?: number; signal?: A

2486

}

25872688

const controller = new AbortController();

27-

const timeoutId = setTimeout(controller.abort.bind(controller), timeoutMs);

89+

const normalizedTimeoutMs = Math.max(1, Math.floor(timeoutMs));

90+

const timeoutId = setTimeout(

91+

abortDueToTimeout,

92+

normalizedTimeoutMs,

93+

controller,

94+

normalizedTimeoutMs,

95+

Date.now(),

96+

params.operation,

97+

params.url,

98+

);

2899

const onAbort = bindAbortRelay(controller);

29100

if (signal) {

30101

if (signal.aborted) {

@@ -63,6 +134,8 @@ export async function fetchWithTimeout(

63134

): Promise<Response> {

64135

const { signal, cleanup } = buildTimeoutAbortSignal({

65136

timeoutMs: Math.max(1, timeoutMs),

137+

operation: "fetchWithTimeout",

138+

url,

66139

});

67140

try {

68141

return await fetchFn(url, { ...init, signal });