The browse daemon client gives every request a fixed 35s socket deadline,
except `open`, which is sized from its navigation timeout. Commands that
wait on the page longer than that are cut off by the transport before the
page action finishes: `browse wait timeout 40000` exits ~39s in with
`Timed out waiting for driver daemon session "<name>".` while the 40s wait
is still running. The same applies to `--timeout 45000` on
reload/back/forward, which the README documents.
`daemonRequestTimeoutMs` now reads the deadline the command itself declared
(`params.timeoutMs`, plus `arg` for `wait timeout <ms>`) and keeps the
socket alive for that long plus 5s of headroom, clamped to the transport
default on the low side and to Node's maximum timer delay on the high side.
Commands that declare nothing — and every unparsable duration — keep
today's 35s deadline, so nothing that works now changes shape.
Tests in `packages/cli/tests/daemon-command-timeout.test.ts` cover the
default, `wait timeout`, a navigation `timeoutMs`, a command asking for
less than the default, an unparsable duration, and the timer cap.
Refs #3369.
What breaks
daemonRequestTimeoutMsgives every request a fixed 35s socket deadline, exceptopen, which is sized from its navigation timeout:Commands that wait on the page longer than that are killed by the transport before the page action finishes.
browse wait timeout 40000exits at ~39s withTimed out waiting for driver daemon session "<name>".while the 40s wait is still in flight; the same applies to the documented--timeout 45000onreload/back/forward.Fix
daemonRequestTimeoutMsnow reads the deadline the command itself declared and keeps the socket open for it:wait{type:"selector"}(no declared timeout)wait{type:"timeout", arg:"40000"}reload{timeoutMs:45000}wait{type:"timeout", arg:"1000"}wait{type:"timeout", arg:"soon"}2_147_483_647The sources are the two places the handlers already read their page timeout from:
params.timeoutMs(navigation, selector/load waits) andparams.argforwait timeout <ms>(commands/runtime.tsparses exactly that). 5s of headroom covers the round trip and the action's own teardown. Commands that declare nothing keep today's 35s, so the change cannot stretch an unrelated request.Tests
New
packages/cli/tests/daemon-command-timeout.test.ts(6 cases, one per row above).3 failed | 3 passed— thewait timeout 40000case fails withexpected 35000 to be 45000, which is the reported abort.6 passed (6).Run in an isolated vitest harness with the driver closure taken verbatim from main
18b96f2(@browserbasehq/*andsession-managerare not needed by theclient.tsclosure and were not installed).Not verified / evidence boundary: no live remote browser session, so the end-to-end
browse wait timeout 40000run from the report was not repeated here — the assertion is on the deadline the client computes, which is the exact value the abort happens at.tsc --noEmitover the isolated closure reports 9 diagnostics, all in files this PR does not touch (server.ts,remote-types.ts,commands/types.ts) and all from the missing third-party types above;daemon/client.tsitself is clean.Summary by cubic
Fixes #3369. The daemon transport imposed a fixed 35s socket deadline on every command except
open, sobrowse wait timeout 40000and--timeout 45000onreload/back/forwardwere aborted mid-wait withTimed out waiting for driver daemon session.daemonRequestTimeoutMsnow derives the deadline from the command's own page timeout —params.timeoutMs, orwait timeout <ms>'sarg— plus 5s headroom for the round trip and teardown.Notes for review
daemon-command-timeout.test.tscovers the default, long and shortwait timeout, a navigation timeout, an unparsable duration, and the cap.Written for commit 01bf51d. Summary will update on new commits.