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

推荐订阅源

D
Docker
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
美团技术团队
雷峰网
雷峰网
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
T
Tailwind CSS Blog
U
Unit 42
C
Check Point Blog
S
SegmentFault 最新的问题
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
L
LangChain Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
罗磊的独立博客
小众软件
小众软件
Recent Announcements
Recent Announcements
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
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(browser): honor Chrome MCP tab timeouts · openclaw/op...
MonkeyLeeT · 2026-06-04 · via Recent Commits to openclaw:main

@@ -1,3 +1,4 @@

1+

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

12

import {

23

BrowserProfileUnavailableError,

34

BrowserTabNotFoundError,

@@ -8,13 +9,16 @@ import {

89

assertBrowserNavigationResultAllowed,

910

withBrowserNavigationPolicy,

1011

} from "../navigation-guard.js";

12+

import { getBrowserProfileCapabilities } from "../profile-capabilities.js";

1113

import type { BrowserRouteContext, ProfileContext } from "../server-context.js";

1214

import { resolveTargetIdFromTabs } from "../target-id.js";

1315

import { browserNavigationPolicyForProfile, resolveProfileContext } from "./agent.shared.js";

1416

import { readRouteNonNegativeInteger } from "./route-numeric.js";

1517

import type { BrowserRequest, BrowserResponse, BrowserRouteRegistrar } from "./types.js";

1618

import { asyncBrowserRoute, jsonError, toStringOrEmpty } from "./utils.js";

171920+

const DEFAULT_TAB_REACHABILITY_TIMEOUT_MS = 300;

21+1822

function handleTabsRouteError(

1923

ctx: BrowserRouteContext,

2024

res: BrowserResponse,

@@ -48,8 +52,37 @@ async function withTabsProfileRoute(params: {

4852

}

4953

}

505451-

async function ensureBrowserRunning(profileCtx: ProfileContext, res: BrowserResponse) {

52-

if (!(await profileCtx.isReachable(300))) {

55+

function resolveTabReachabilityTimeoutMs(

56+

ctx: BrowserRouteContext,

57+

profileCtx: ProfileContext,

58+

): number {

59+

if (!getBrowserProfileCapabilities(profileCtx.profile).usesChromeMcp) {

60+

return DEFAULT_TAB_REACHABILITY_TIMEOUT_MS;

61+

}

62+

return (

63+

clampPositiveTimerTimeoutMs(ctx.state().resolved.actionTimeoutMs) ??

64+

DEFAULT_TAB_REACHABILITY_TIMEOUT_MS

65+

);

66+

}

67+68+

async function checkTabReachability(

69+

ctx: BrowserRouteContext,

70+

profileCtx: ProfileContext,

71+

signal?: AbortSignal,

72+

) {

73+

const timeoutMs = resolveTabReachabilityTimeoutMs(ctx, profileCtx);

74+

return signal

75+

? await profileCtx.isReachable(timeoutMs, { signal })

76+

: await profileCtx.isReachable(timeoutMs);

77+

}

78+79+

async function ensureBrowserRunning(

80+

ctx: BrowserRouteContext,

81+

profileCtx: ProfileContext,

82+

res: BrowserResponse,

83+

signal?: AbortSignal,

84+

) {

85+

if (!(await checkTabReachability(ctx, profileCtx, signal))) {

5386

jsonError(

5487

res,

5588

new BrowserProfileUnavailableError("browser not running").status,

@@ -149,7 +182,7 @@ async function runTabTargetMutation(params: {

149182

ctx: params.ctx,

150183

mapTabError: true,

151184

run: async (profileCtx) => {

152-

if (!(await ensureBrowserRunning(profileCtx, params.res))) {

185+

if (!(await ensureBrowserRunning(params.ctx, profileCtx, params.res, params.req.signal))) {

153186

return;

154187

}

155188

await params.mutate(profileCtx, params.targetId);

@@ -167,7 +200,7 @@ export function registerBrowserTabRoutes(app: BrowserRouteRegistrar, ctx: Browse

167200

res,

168201

ctx,

169202

run: async (profileCtx) => {

170-

const reachable = await profileCtx.isReachable(300);

203+

const reachable = await checkTabReachability(ctx, profileCtx, req.signal);

171204

if (!reachable) {

172205

return res.json({ running: false, tabs: [] as unknown[] });

173206

}

@@ -277,7 +310,7 @@ export function registerBrowserTabRoutes(app: BrowserRouteRegistrar, ctx: Browse

277310

mapTabError: true,

278311

run: async (profileCtx) => {

279312

if (action === "list") {

280-

const reachable = await profileCtx.isReachable(300);

313+

const reachable = await checkTabReachability(ctx, profileCtx, req.signal);

281314

if (!reachable) {

282315

return res.json({ ok: true, tabs: [] as unknown[] });

283316

}

@@ -297,7 +330,7 @@ export function registerBrowserTabRoutes(app: BrowserRouteRegistrar, ctx: Browse

297330

}

298331299332

if (action === "label") {

300-

if (!(await ensureBrowserRunning(profileCtx, res))) {

333+

if (!(await ensureBrowserRunning(ctx, profileCtx, res, req.signal))) {

301334

return;

302335

}

303336

const targetId = parseRequiredTargetId(

@@ -316,7 +349,7 @@ export function registerBrowserTabRoutes(app: BrowserRouteRegistrar, ctx: Browse

316349

}

317350318351

if (action === "close") {

319-

if (!(await ensureBrowserRunning(profileCtx, res))) {

352+

if (!(await ensureBrowserRunning(ctx, profileCtx, res, req.signal))) {

320353

return;

321354

}

322355

const index = readTabIndex(res, req.body);

@@ -337,7 +370,7 @@ export function registerBrowserTabRoutes(app: BrowserRouteRegistrar, ctx: Browse

337370

if (index === null || index === undefined) {

338371

return;

339372

}

340-

if (!(await ensureBrowserRunning(profileCtx, res))) {

373+

if (!(await ensureBrowserRunning(ctx, profileCtx, res, req.signal))) {

341374

return;

342375

}

343376

const tabs = await profileCtx.listTabs();