Repository navigation
fix(daemon): honor tool timeouts for CLI responses - #3110
lorenzozanee wants to merge 1 commit into
Conversation
|
@yulunz, please review this PR (automatically distributed) |
yulunz
left a comment
There was a problem hiding this comment.
Thanks for fixing this! Deriving the daemon socket deadline from command.args?.timeout in src/daemon/client.ts makes sense. One small guard for NaN below.
|
|
||
| const toolTimeout = command.args?.timeout; | ||
| if (typeof toolTimeout !== 'number' || toolTimeout <= 0) { | ||
| return SEND_COMMAND_TIMEOUT; |
There was a problem hiding this comment.
When an invalid numeric flag is passed on the CLI (e.g. --timeout foo), yargs parses timeout as NaN. Since typeof NaN === 'number', NaN <= 0 is false, and NaN < SEND_COMMAND_TIMEOUT is false, getCommandResponseTimeout returns NaN (NaN + SEND_COMMAND_TIMEOUT), which causes setTimeout in sendCommand to fire immediately instead of letting the daemon return an input validation error.
Could we disallow NaN here (e.g. Number.isNaN(toolTimeout))?
const toolTimeout = command.args?.timeout;
if (
typeof toolTimeout !== 'number' ||
Number.isNaN(toolTimeout) ||
toolTimeout <= 0
) {
return SEND_COMMAND_TIMEOUT;
}| 60_000, | ||
| ); | ||
| assert.strictEqual(getCommandResponseTimeout({method: 'status'}), 60_000); | ||
| }); |
There was a problem hiding this comment.
Please also add a test case for args: {timeout: Number.NaN} returning 60_000.
|
Closing as stale. Feel free to resolve the issue and merge conflict we can re-open. |
The CLI can stop waiting after 60 seconds even when a tool has a longer explicit timeout, losing the daemon's eventual result. Derive the default response deadline for `invoke_tool` from a finite positive tool timeout plus the existing 60-second response allowance. Missing, nonnumeric, nonfinite, and nonpositive tool timeouts keep the existing default. Explicit socket deadlines remain authoritative, and derived deadlines are capped at Node's maximum timer delay to avoid overflowing into an immediate timeout. This also applies to short positive timeouts: `--timeout 5000` waits up to 65 seconds for the daemon response, instead of the previous 60 seconds. Commands other than `invoke_tool` retain the 60-second default. Follows the timeout approach discussed in ChromeDevTools#3110. Fixes ChromeDevTools#2983. Initial validation at `0c65963`: the daemon client tests pass (27/27). The full suite has 1,815 passes, 3 skips, and one large full-page screenshot failure (`Page is too large`), also reproduced on unmodified `main` at `6b056c8`. Format checks pass. --------- Co-authored-by: Natasha Gorshunova <[email protected]>
Tool invocations with a longer
--timeoutcould still fail after the CLI's fixed 60-second daemon response deadline. Derive the response deadline from the invocation timeout, adding a 60-second grace period for long operations while retaining the existing default for short or non-tool commands.Focused daemon-client tests, typecheck, format check, and
git diff --checkpass. The full suite has Chrome launch failures (TargetCloseError) in this environment.Fixes #2983