Repository navigation
fix(browser): preserve dispatcher errors instead of wrapping as 'can't reach service' - #39090
NewdlDewdl wants to merge 1 commit into
Conversation
…t reach service' When browser control service dispatcher operations time out (e.g. during slow Chrome launch), the error was being wrapped as 'Can't reach the OpenClaw browser control service' even though the service is reachable and the actual issue is an operation timeout inside the service. This change preserves the original error for dispatcher (in-process) paths, making timeout/failure causes (Chrome launch issues, CDP readiness) visible to users instead of misleading them to restart the gateway. Fixes openclaw#39007
Greptile SummaryThis PR fixes misleading error messages in Key changes:
Issue found:
Confidence Score: 3/5
Last reviewed commit: 400900a |
| // For dispatcher paths, timeout/abort errors indicate service operation failure, | ||
| // not network unreachability. Preserve the original error for clearer diagnosis. | ||
| if (isDispatcherPath) { | ||
| throw err; | ||
| } |
There was a problem hiding this comment.
Model retry-loop protection silently dropped for dispatcher path
The enhanceBrowserFetchError function appends a modelHint to every error it produces (line 109–111), with an explicit comment explaining why:
// Model-facing suffix: explicitly tell the LLM NOT to retry.
// Without this, models see "try again" and enter an infinite tool-call loop.By re-throwing the raw dispatcher error here, that hint is no longer present on any error originating from the dispatcher path — including Chrome CDP timeouts, "browser control disabled", and any other failure from startBrowserControlServiceFromConfig() or dispatcher.dispatch(). An LLM receiving a bare "Chrome CDP websocket not reachable after start" message has no explicit instruction to stop retrying and may enter the same infinite tool-call loop the hint was designed to prevent.
A more surgical fix would preserve the model hint while dropping the misleading "Can't reach…" wrapper:
if (isDispatcherPath) {
const modelHint =
"Do NOT retry the browser tool — it will keep failing. " +
"Use an alternative approach or inform the user that the browser is currently unavailable.";
const base = err instanceof Error ? err.message : String(err);
throw new Error(`${base} ${modelHint}`);
}Or, alternatively, refactor enhanceBrowserFetchError to accept an isDispatcherPath flag so it can skip the "Can't reach…" prefix while still appending the model hint.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/browser/client-fetch.ts
Line: 256-260
Comment:
**Model retry-loop protection silently dropped for dispatcher path**
The `enhanceBrowserFetchError` function appends a `modelHint` to every error it produces (line 109–111), with an explicit comment explaining why:
```typescript
// Model-facing suffix: explicitly tell the LLM NOT to retry.
// Without this, models see "try again" and enter an infinite tool-call loop.
```
By re-throwing the raw dispatcher error here, that hint is no longer present on any error originating from the dispatcher path — including Chrome CDP timeouts, `"browser control disabled"`, and any other failure from `startBrowserControlServiceFromConfig()` or `dispatcher.dispatch()`. An LLM receiving a bare `"Chrome CDP websocket not reachable after start"` message has no explicit instruction to stop retrying and may enter the same infinite tool-call loop the hint was designed to prevent.
A more surgical fix would preserve the model hint while dropping the misleading "Can't reach…" wrapper:
```typescript
if (isDispatcherPath) {
const modelHint =
"Do NOT retry the browser tool — it will keep failing. " +
"Use an alternative approach or inform the user that the browser is currently unavailable.";
const base = err instanceof Error ? err.message : String(err);
throw new Error(`${base} ${modelHint}`);
}
```
Or, alternatively, refactor `enhanceBrowserFetchError` to accept an `isDispatcherPath` flag so it can skip the "Can't reach…" prefix while still appending the model hint.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Addressed in commit 874f5ad — preserved dispatcher error context while appending the browser no-retry hint to prevent retry loops.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 400900a5ed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (isDispatcherPath) { | ||
| throw err; |
There was a problem hiding this comment.
Keep no-retry guidance for dispatcher errors
This new isDispatcherPath early rethrow skips enhanceBrowserFetchError for all in-process browser calls, so timeout/abort failures no longer include the Do NOT retry the browser tool instruction that this module explicitly relies on to prevent retry loops. In the default local-dispatch path (no HTTP base URL), models will now receive raw timeout errors and can re-enter repeated tool calls instead of failing fast with guidance, which is a behavioral regression even though the root cause message is preserved.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in commit 874f5ad — preserved dispatcher error context while appending the browser no-retry hint to prevent retry loops.
Landed from #39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]>
|
Landed on What we changed while landing:
Source commit reviewed: Thanks @NewdlDewdl. |
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]>
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]>
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]>
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]>
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]>
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]> (cherry picked from commit 9b4a114)
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]> (cherry picked from commit 9b4a114)
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]>
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]>
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]>
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]>
Landed from openclaw#39090 by @NewdlDewdl. Co-authored-by: NewdlDewdl <[email protected]>
Problem
When browser control service dispatcher operations time out (e.g., during slow Chrome launch), the error is wrapped as "Can't reach the OpenClaw browser control service" even when the service is reachable. This misleads users into thinking the gateway needs to be restarted, when the actual issue is an operation timeout inside the service (Chrome launch, CDP readiness, etc.).
Solution
Preserve the original error for dispatcher (in-process) paths. Only apply the "Can't reach..." wrapper for network errors on HTTP paths. This makes the actual timeout/failure cause visible to users.
Testing
Fixes #39007