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

推荐订阅源

罗磊的独立博客
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
IT之家
IT之家
B
Blog
博客园_首页
博客园 - 司徒正美
有赞技术团队
有赞技术团队
博客园 - 聂微东
I
InfoQ
美团技术团队
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
H
Help Net Security
大猫的无限游戏
大猫的无限游戏
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Cloudflare 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(browser): align bare ws cdp readiness · openclaw/open...
steipete · 2026-04-25 · via Recent Commits to openclaw:main

@@ -6,6 +6,7 @@ import os from "node:os";

66

import path from "node:path";

77

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

88

import { WebSocketServer } from "ws";

9+

import { rawDataToString } from "../infra/ws.js";

910

import {

1011

parseBrowserMajorVersion,

1112

resolveGoogleChromeExecutableForPlatform,

@@ -56,7 +57,7 @@ async function withMockChromeCdpServer(params: {

5657

run: (baseUrl: string) => Promise<void>;

5758

}) {

5859

const server = createServer((req, res) => {

59-

if (req.url === "/json/version") {

60+

if (req.url?.startsWith("/json/version")) {

6061

const addr = server.address() as AddressInfo;

6162

res.writeHead(200, { "Content-Type": "application/json" });

6263

res.end(

@@ -71,7 +72,7 @@ async function withMockChromeCdpServer(params: {

7172

});

7273

const wss = new WebSocketServer({ noServer: true });

7374

server.on("upgrade", (req, socket, head) => {

74-

if (req.url !== params.wsPath) {

75+

if (!req.url?.startsWith(params.wsPath)) {

7576

socket.destroy();

7677

return;

7778

}

@@ -630,6 +631,37 @@ describe("browser chrome helpers", () => {

630631

});

631632

});

632633634+

it("uses HTTP discovery before readiness checks for a bare ws:// CDP URL", async () => {

635+

await withMockChromeCdpServer({

636+

wsPath: "/devtools/browser/READY",

637+

onConnection: (wss) => {

638+

wss.on("connection", (ws) => {

639+

ws.on("message", (raw) => {

640+

const message = JSON.parse(rawDataToString(raw)) as { id?: number; method?: string };

641+

if (message.method === "Browser.getVersion" && message.id === 1) {

642+

ws.send(

643+

JSON.stringify({

644+

id: 1,

645+

result: { product: "Chrome/Mock" },

646+

}),

647+

);

648+

}

649+

});

650+

});

651+

},

652+

run: async (baseUrl) => {

653+

const url = new URL(baseUrl);

654+

const wsOnlyBase = `ws://${url.host}?token=abc`;

655+

await expect(isChromeCdpReady(wsOnlyBase, 300, 400)).resolves.toBe(true);

656+

const diagnostic = await diagnoseChromeCdp(wsOnlyBase, 300, 400);

657+

expect(diagnostic).toMatchObject({

658+

ok: true,

659+

wsUrl: `ws://${url.host}/devtools/browser/READY?token=abc`,

660+

});

661+

},

662+

});

663+

});

664+633665

it("reports unreachable when a bare ws:// CDP URL points at a server with no /json/version and refuses WS", async () => {

634666

// Negative counterpart to the #68027 happy path — a bare ws URL

635667

// pointed at a port that neither serves /json/version nor accepts

@@ -664,6 +696,36 @@ describe("browser chrome helpers", () => {

664696

}

665697

});

666698699+

it("falls back to a direct WS readiness check when /json/version has no debugger URL", async () => {

700+

vi.stubGlobal(

701+

"fetch",

702+

vi.fn().mockResolvedValue({

703+

ok: true,

704+

json: async () => ({}),

705+

} as unknown as Response),

706+

);

707+

const wss = new WebSocketServer({ port: 0, host: "127.0.0.1" });

708+

wss.on("connection", (ws) => {

709+

ws.on("message", (raw) => {

710+

const message = JSON.parse(rawDataToString(raw)) as { id?: number; method?: string };

711+

if (message.method === "Browser.getVersion" && message.id === 1) {

712+

ws.send(JSON.stringify({ id: 1, result: { product: "Browserless/Mock" } }));

713+

}

714+

});

715+

});

716+

await new Promise<void>((resolve) => wss.once("listening", () => resolve()));

717+

const port = (wss.address() as AddressInfo).port;

718+

try {

719+

await expect(isChromeCdpReady(`ws://127.0.0.1:${port}`, 500, 500)).resolves.toBe(true);

720+

await expect(diagnoseChromeCdp(`ws://127.0.0.1:${port}`, 500, 500)).resolves.toMatchObject({

721+

ok: true,

722+

wsUrl: `ws://127.0.0.1:${port}`,

723+

});

724+

} finally {

725+

await new Promise<void>((resolve) => wss.close(() => resolve()));

726+

}

727+

});

728+667729

it("returns the original ws:// URL from getChromeWebSocketUrl when /json/version provides no debugger URL", async () => {

668730

// Covers the getChromeWebSocketUrl WS-fallback: discovery succeeds but

669731

// webSocketDebuggerUrl is absent — the original URL is returned as-is.