fix(browser): derive cdp port from control url
This commit is contained in:
@@ -38,6 +38,14 @@ describe("browser config", () => {
|
||||
expect(shouldStartLocalBrowserServer(resolved)).toBe(false);
|
||||
});
|
||||
|
||||
it("derives CDP port as control port + 1", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
controlUrl: "http://127.0.0.1:19000",
|
||||
});
|
||||
expect(resolved.controlPort).toBe(19000);
|
||||
expect(resolved.cdpPort).toBe(19001);
|
||||
});
|
||||
|
||||
it("rejects unsupported protocols", () => {
|
||||
expect(() =>
|
||||
resolveBrowserConfig({ controlUrl: "ws://127.0.0.1:18790" }),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { BrowserConfig } from "../config/config.js";
|
||||
import {
|
||||
DEFAULT_CLAWD_BROWSER_CDP_PORT,
|
||||
DEFAULT_CLAWD_BROWSER_COLOR,
|
||||
DEFAULT_CLAWD_BROWSER_CONTROL_URL,
|
||||
DEFAULT_CLAWD_BROWSER_ENABLED,
|
||||
@@ -55,7 +54,12 @@ export function resolveBrowserConfig(
|
||||
throw new Error(`browser.controlUrl has invalid port: ${parsed.port}`);
|
||||
}
|
||||
|
||||
const cdpPort = DEFAULT_CLAWD_BROWSER_CDP_PORT;
|
||||
const cdpPort = port + 1;
|
||||
if (cdpPort > 65535) {
|
||||
throw new Error(
|
||||
`browser.controlUrl port (${port}) is too high; cannot derive CDP port (${cdpPort})`,
|
||||
);
|
||||
}
|
||||
if (port === cdpPort) {
|
||||
throw new Error(
|
||||
`browser.controlUrl port (${port}) must not equal CDP port (${cdpPort})`,
|
||||
|
||||
Reference in New Issue
Block a user