fix(browser): derive cdp port from control url
parent
208ba02a4a
commit
2d36ae6326
|
|
@ -38,6 +38,14 @@ describe("browser config", () => {
|
||||||
expect(shouldStartLocalBrowserServer(resolved)).toBe(false);
|
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", () => {
|
it("rejects unsupported protocols", () => {
|
||||||
expect(() =>
|
expect(() =>
|
||||||
resolveBrowserConfig({ controlUrl: "ws://127.0.0.1:18790" }),
|
resolveBrowserConfig({ controlUrl: "ws://127.0.0.1:18790" }),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import type { BrowserConfig } from "../config/config.js";
|
import type { BrowserConfig } from "../config/config.js";
|
||||||
import {
|
import {
|
||||||
DEFAULT_CLAWD_BROWSER_CDP_PORT,
|
|
||||||
DEFAULT_CLAWD_BROWSER_COLOR,
|
DEFAULT_CLAWD_BROWSER_COLOR,
|
||||||
DEFAULT_CLAWD_BROWSER_CONTROL_URL,
|
DEFAULT_CLAWD_BROWSER_CONTROL_URL,
|
||||||
DEFAULT_CLAWD_BROWSER_ENABLED,
|
DEFAULT_CLAWD_BROWSER_ENABLED,
|
||||||
|
|
@ -55,7 +54,12 @@ export function resolveBrowserConfig(
|
||||||
throw new Error(`browser.controlUrl has invalid port: ${parsed.port}`);
|
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) {
|
if (port === cdpPort) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`browser.controlUrl port (${port}) must not equal CDP port (${cdpPort})`,
|
`browser.controlUrl port (${port}) must not equal CDP port (${cdpPort})`,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue