chore(browser): format CDP helpers

This commit is contained in:
Peter Steinberger
2026-01-01 16:19:37 +00:00
parent c8c84bc419
commit a248bea50f
2 changed files with 14 additions and 13 deletions

View File

@@ -353,14 +353,17 @@ async function canOpenWebSocket(
): Promise<boolean> {
return await new Promise<boolean>((resolve) => {
const ws = new WebSocket(wsUrl, { handshakeTimeout: timeoutMs });
const timer = setTimeout(() => {
try {
ws.terminate();
} catch {
// ignore
}
resolve(false);
}, Math.max(50, timeoutMs + 25));
const timer = setTimeout(
() => {
try {
ws.terminate();
} catch {
// ignore
}
resolve(false);
},
Math.max(50, timeoutMs + 25),
);
ws.once("open", () => {
clearTimeout(timer);
try {

View File

@@ -1,8 +1,9 @@
import fs from "node:fs";
import type { Server } from "node:http";
import os from "node:os";
import path from "node:path";
import type { Server } from "node:http";
import { runExec } from "../process/exec.js";
import { createTargetViaCdp } from "./cdp.js";
import {
isChromeCdpReady,
@@ -14,7 +15,6 @@ import {
} from "./chrome.js";
import type { ResolvedBrowserConfig } from "./config.js";
import { resolveTargetIdFromTabs } from "./target-id.js";
import { runExec } from "../process/exec.js";
export type BrowserTab = {
targetId: string;
@@ -223,9 +223,7 @@ export function createBrowserRouteContext(
attachRunning(relaunched);
if (!(await isReachable(600))) {
throw new Error(
"Chrome CDP websocket is not reachable after restart.",
);
throw new Error("Chrome CDP websocket is not reachable after restart.");
}
};