aboutsummaryrefslogtreecommitdiff
path: root/src/cdp
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmail.com>2026-07-28 21:48:35 +0530
committerAman Kumar <145339995+amankumarsingh77@users.noreply.github.com>2026-08-02 19:12:46 +0530
commit6d300099a86cfdb92b7869dc2b4f33094554b24c (patch)
tree56ea6be73ac8b92d4ae4a2731e8d41dd54e876f7 /src/cdp
parentaedbb88a8025851067be9f77ec406b29d65599a8 (diff)
fix: make --browser-debug-clicks and BU_CDP_WS actually work
Both were documented and inert. --browser-debug-clicks was registered as a flag and never read; the only real switch was the undocumented BH_DEBUG_CLICKS env var. The flag now feeds util/debug.ts, which the click tool consults, and the env var keeps working as an equivalent. BU_CDP_WS was read in the client and handed to transport.connect(), but the daemon transport discards that argument and always dials the daemon socket — and the daemon's own discovery never looked at the variable, so setting it did nothing. The override now lives in discoverEndpoint, which is what both processes go through, and the client's redundant read is gone. The variable must be set before the daemon spawns. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src/cdp')
-rw-r--r--src/cdp/discovery.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cdp/discovery.ts b/src/cdp/discovery.ts
index f33adc6..60fb14f 100644
--- a/src/cdp/discovery.ts
+++ b/src/cdp/discovery.ts
@@ -101,7 +101,16 @@ type Candidate = {
readonly userDataDir: string;
};
+// Read here rather than in the client: the daemon owns the only socket to Chrome, so an override the daemon cannot see has no effect.
+export const endpointFromEnv = (env: NodeJS.ProcessEnv = process.env): CdpEndpoint | undefined => {
+ const wsUrl = env["BU_CDP_WS"]?.trim();
+ return wsUrl ? { wsUrl } : undefined;
+};
+
export const discoverEndpoint = async (): Promise<Result<CdpEndpoint, CdpError>> => {
+ const override = endpointFromEnv();
+ if (override) return ok(override);
+
const dirs = userDataDirCandidates();
const candidates: Candidate[] = [];