Skip to content

Commit 75a0fb4

Browse files
author
probe
committed
tmp: log every slow CDP command and keep the 15s budget
1 parent 3e6b2eb commit 75a0fb4

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎packages/webui/src/runtime/browser/isolated-chromium/cdp-connection.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import WebSocket from "ws";
2424
import { browserOperationError } from "../errors.js";
2525

2626
/** How long a single CDP command may take before it is abandoned. */
27-
export const WEBUI_BROWSER_CDP_COMMAND_TIMEOUT_MS = 120_000;
27+
export const WEBUI_BROWSER_CDP_COMMAND_TIMEOUT_MS = 15_000;
2828

2929
/** How long the WebSocket handshake may take. */
3030
export const WEBUI_BROWSER_CDP_HANDSHAKE_TIMEOUT_MS = 10_000;
@@ -116,6 +116,21 @@ export class WebuiBrowserCdpConnection {
116116
params: Record<string, unknown> = {},
117117
sessionId?: string,
118118
options: { readonly signal?: AbortSignal; readonly timeoutMs?: number } = {},
119+
): Promise<T> {
120+
const startedAt = Date.now();
121+
try {
122+
return await this.#send(method, params, sessionId, options);
123+
} finally {
124+
const elapsed = Date.now() - startedAt;
125+
if (elapsed >= 300) console.log(`[DIAG-CDP] ${method} took ${elapsed}ms`);
126+
}
127+
}
128+
129+
async #send<T = unknown>(
130+
method: string,
131+
params: Record<string, unknown> = {},
132+
sessionId?: string,
133+
options: { readonly signal?: AbortSignal; readonly timeoutMs?: number } = {},
119134
): Promise<T> {
120135
if (this.#closed) {
121136
throw browserOperationError(

0 commit comments

Comments
 (0)