Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(socketService): correct debug namespace setup for browser and test environments

Steven Enamakel0c38b3dbf2b2
diff --git a/app/src/services/socketService.ts b/app/src/services/socketService.ts
index 832ff83f25..d7bcc1a595 100644
--- a/app/src/services/socketService.ts
+++ b/app/src/services/socketService.ts
@@ -25,13 +25,21 @@ import { getCoreRpcToken, getCoreRpcUrl } from './coreRpcClient';
import { createCoreSocket } from './coreSocket';
// Socket service logger using debug package
-// Enable logging by setting DEBUG=socket* in environment or localStorage
+// To change these namespaces at runtime, set `localStorage.debug` — NOT the
+// DEBUG env var. Under jsdom (and in the browser) the `debug` package resolves
+// to its `browser` build, which reads `localStorage.debug` and ignores
+// `process.env.DEBUG` entirely, so `DEBUG=socket* pnpm test` silently does
+// nothing. The previous comment here claimed otherwise and cost real time.
const socketLog = debug('socket');
const socketWarn = debug('socket:warn');
const socketError = debug('socket:error');
-// Enable socket logging in development by default
-if (IS_DEV) {
+// Enable socket logging in development by default — but never under test.
+// `IS_DEV` is truthy in vitest, so without the MODE guard this force-enable
+// floods every test file that imports this service (measured: 412 lines /
+// 46KB of `flow:approval_request` listener churn in a single run), inflating
+// runtime enough to push suites past the runner's foreground timeout.
+if (IS_DEV && import.meta.env.MODE !== 'test') {
debug.enable('socket*');
}