Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: stop browser CDP keep-alive from spamming JSON-parse errors on a non-Chrome port

[._.]/ Adam Eivy81bbcbad887d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index eaf368f4b9..3e285f5cca 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -21,3 +21,7 @@
- **[issue-875] CyberCity district layout internals consolidated** — the city's districts now share one set of layout primitives for grid placement, category tallies, and log-scaled building heights, so each district no longer carries its own copy of that math. No visible change to the city.
- **[issue-713] Simpler, collapsed sidebar** — The left navigation is consolidated to a focused set of top-level areas with a "More" group for the long tail. Messaging and your wiki now live under Brain, system and infrastructure tools under Dev Tools, and health tracking is now simply "Health"; Goals is promoted to its own top-level entry. Deep page tabs no longer clutter the sidebar — open a page and its tabs live in the page — and everything stays reachable from ⌘K and voice navigation.
- **[issue-919] Internal: shared-helper catalog for the client utility modules** — Added a discovery index and a drift-guard test so the client's pure helper modules stay easy to find and can't silently fall out of the catalog. No user-facing change.
+
+## Fixed
+
+- **Browser download keep-alive no longer spams JSON-parse errors** — The browser service's CDP keep-alive treated any `200 OK` on its DevTools port as a live Chrome endpoint and called `res.json()` on it unconditionally. When another process answers on that port with HTML (e.g. the Vite dev server auto-incrementing onto it), the parse threw `Unexpected token '<', "<!DOCTYPE "...`, which the reconnect loop logged every 2 seconds. The CDP check now validates the response is actually Chrome's JSON (`webSocketDebuggerUrl` present) and treats anything else as "not reachable." Separately, the Vite dev server now uses `strictPort` so it fails loudly instead of silently walking up onto a reserved PortOS port (5555 API, 5556 browser CDP).
diff --git a/browser/server.js b/browser/server.js
index c53ec718c9..5090e6e39c 100644
--- a/browser/server.js
+++ b/browser/server.js
@@ -73,7 +73,15 @@ async function checkCdp() {
const res = await fetch(`http://${CDP_HOST}:${CDP_PORT}/json/version`, { signal: controller.signal }).catch(() => null);
clearTimeout(timeout);
if (!res?.ok) return null;
- return res.json();
+ // A 200 here doesn't guarantee it's Chrome's CDP endpoint — something else
+ // (a stray dev server, a captive portal, a Chrome HTML error page) can answer
+ // on this port with `<!DOCTYPE html>…`. `res.json()` would then reject with
+ // "Unexpected token '<'", and that rejection escapes through every caller —
+ // most visibly spamming scheduleDownloadReconnect()'s catch every 2s. Treat
+ // any non-JSON or non-CDP body as "not reachable" by returning null.
+ const version = await res.json().catch(() => null);
+ if (!version?.webSocketDebuggerUrl) return null;
+ return version;
}
// Chrome's `Browser.setDownloadBehavior` is DevTools-session-scoped — when the
diff --git a/client/vite.config.js b/client/vite.config.js
index 1fdafd6e2c..d76aa9c047 100644
--- a/client/vite.config.js
+++ b/client/vite.config.js
@@ -36,6 +36,11 @@ export default defineConfig(({ mode }) => {
server: {
host: '0.0.0.0',
port: 5554,
+ // Fail loudly if 5554 is taken instead of auto-incrementing. Without this,
+ // Vite walks up to the next free port and can land on a reserved PortOS
+ // port (5555 API, 5556 browser CDP) — squatting on the CDP port makes the
+ // browser keep-alive read Vite's HTML index and spam JSON-parse errors.
+ strictPort: true,
open: false,
allowedHosts: ['.ts.net', 'localhost'],
proxy: {