Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(screen-worker): give Chrome 60s to open its debug port at boot

nirholasc49b6fe38ca6
diff --git a/workers/agent-screen-worker/config.js b/workers/agent-screen-worker/config.js
index 98afe89bc..e73534b0a 100644
--- a/workers/agent-screen-worker/config.js
+++ b/workers/agent-screen-worker/config.js
@@ -60,6 +60,12 @@ export function loadConfig() {
* sandboxed browser as uid 0, which is the default inside a container, so the
* sandbox is dropped only in that case. `CHROME_NO_SANDBOX=1` forces it off for
* hosts whose kernel blocks user namespaces even for an unprivileged user.
+ *
+ * Stagehand allows 15s for Chrome to open its debug port. A first launch on a
+ * loaded or throttled host regularly needs longer, and overrunning it kills the
+ * worker at boot with a bare ECONNREFUSED that reads like a network fault rather
+ * than a slow browser. 60s costs nothing on a fast host (the wait ends as soon
+ * as the port answers) and turns that crash into a normal cold start.
*/
function localLaunchOptions() {
const runningAsRoot = typeof process.getuid === 'function' && process.getuid() === 0;
@@ -72,6 +78,7 @@ function localLaunchOptions() {
...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}),
headless: process.env.CHROME_HEADLESS !== '0',
chromiumSandbox: !noSandbox,
+ connectTimeoutMs: Number(process.env.CHROME_CONNECT_TIMEOUT_MS || 60_000),
args,
};
}