fix(browser): extend existing-session status probe · openclaw/openclaw@f654f2f
2026-05-10
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -323,6 +323,12 @@ describe("browser client", () => {
|
323 | 323 | expect.stringMatching(/\/doctor\?profile=openclaw&deep=true$/), |
324 | 324 | ]), |
325 | 325 | ); |
| 326 | +const status = calls.find((c) => c.url.endsWith("/")); |
| 327 | +expect(status?.init?.timeoutMs).toBe(7_500); |
| 328 | +const doctor = calls.find((c) => c.url.endsWith("/doctor")); |
| 329 | +expect(doctor?.init?.timeoutMs).toBe(7_500); |
| 330 | +const deepDoctor = calls.find((c) => c.url.endsWith("/doctor?profile=openclaw&deep=true")); |
| 331 | +expect(deepDoctor?.init?.timeoutMs).toBe(10_000); |
326 | 332 | const open = calls.find((c) => c.url.endsWith("/tabs/open")); |
327 | 333 | expect(open?.init?.method).toBe("POST"); |
328 | 334 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,10 @@ import type { BrowserDoctorReport } from "./doctor.js";
|
11 | 11 | export type { BrowserStatus, BrowserTab, BrowserTransport } from "./client.types.js"; |
12 | 12 | export type { BrowserDoctorCheck, BrowserDoctorReport } from "./doctor.js"; |
13 | 13 | |
| 14 | +const BROWSER_STATUS_REQUEST_TIMEOUT_MS = 7_500; |
| 15 | +const BROWSER_DOCTOR_REQUEST_TIMEOUT_MS = 7_500; |
| 16 | +const BROWSER_DEEP_DOCTOR_REQUEST_TIMEOUT_MS = 10_000; |
| 17 | + |
14 | 18 | export type ProfileStatus = { |
15 | 19 | name: string; |
16 | 20 | transport?: BrowserTransport; |
@@ -71,7 +75,7 @@ export async function browserStatus(
|
71 | 75 | timeoutMs: |
72 | 76 | typeof opts?.timeoutMs === "number" && Number.isFinite(opts.timeoutMs) |
73 | 77 | ? Math.max(1, Math.floor(opts.timeoutMs)) |
74 | | - : 1500, |
| 78 | + : BROWSER_STATUS_REQUEST_TIMEOUT_MS, |
75 | 79 | }); |
76 | 80 | } |
77 | 81 | |
@@ -88,7 +92,9 @@ export async function browserDoctor(
|
88 | 92 | } |
89 | 93 | const q = params.size ? `?${params.toString()}` : ""; |
90 | 94 | return await fetchBrowserJson<BrowserDoctorReport>(withBaseUrl(baseUrl, `/doctor${q}`), { |
91 | | -timeoutMs: opts?.deep ? 10000 : 3000, |
| 95 | +timeoutMs: opts?.deep |
| 96 | + ? BROWSER_DEEP_DOCTOR_REQUEST_TIMEOUT_MS |
| 97 | + : BROWSER_DOCTOR_REQUEST_TIMEOUT_MS, |
92 | 98 | }); |
93 | 99 | } |
94 | 100 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -302,6 +302,7 @@ describe("basic browser routes", () => {
|
302 | 302 | |
303 | 303 | expect(response.statusCode).toBe(200); |
304 | 304 | expect(isTransportAvailable).toHaveBeenCalledTimes(1); |
| 305 | +expect(isTransportAvailable).toHaveBeenCalledWith(5_000); |
305 | 306 | expect(isHttpReachable).not.toHaveBeenCalled(); |
306 | 307 | expect(response.body).toMatchObject({ |
307 | 308 | cdpHttp: true, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,6 +17,10 @@ import {
|
17 | 17 | toStringOrEmpty, |
18 | 18 | } from "./utils.js"; |
19 | 19 | |
| 20 | +const STATUS_CDP_HTTP_TIMEOUT_MS = 300; |
| 21 | +const STATUS_CDP_TRANSPORT_TIMEOUT_MS = 600; |
| 22 | +const STATUS_CHROME_MCP_TRANSPORT_TIMEOUT_MS = 5_000; |
| 23 | + |
20 | 24 | function handleBrowserRouteError(res: BrowserResponse, err: unknown) { |
21 | 25 | const mapped = toBrowserErrorResponse(err); |
22 | 26 | if (mapped) { |
@@ -72,10 +76,13 @@ async function buildBrowserStatus(req: BrowserRequest, ctx: BrowserRouteContext)
|
72 | 76 | const capabilities = getBrowserProfileCapabilities(profileCtx.profile); |
73 | 77 | const [cdpHttp, cdpReady] = capabilities.usesChromeMcp |
74 | 78 | ? await (async () => { |
75 | | -const ready = await profileCtx.isTransportAvailable(600); |
| 79 | +const ready = await profileCtx.isTransportAvailable(STATUS_CHROME_MCP_TRANSPORT_TIMEOUT_MS); |
76 | 80 | return [ready, ready] as const; |
77 | 81 | })() |
78 | | - : await Promise.all([profileCtx.isHttpReachable(300), profileCtx.isTransportAvailable(600)]); |
| 82 | + : await Promise.all([ |
| 83 | +profileCtx.isHttpReachable(STATUS_CDP_HTTP_TIMEOUT_MS), |
| 84 | +profileCtx.isTransportAvailable(STATUS_CDP_TRANSPORT_TIMEOUT_MS), |
| 85 | +]); |
79 | 86 | |
80 | 87 | const profileState = current.profiles.get(profileCtx.profile.name); |
81 | 88 | let detectedBrowser: string | null = null; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。