Skip to content

fix(browser): preserve dispatcher errors instead of wrapping as 'can't reach service' - #39090

Closed
NewdlDewdl wants to merge 1 commit into
openclaw:mainfrom
NewdlDewdl:fix/issue-39007-browser-timeout-message
Closed

NewdlDewdl wants to merge 1 commit into
openclaw:mainfrom
NewdlDewdl:fix/issue-39007-browser-timeout-message

Conversation

@NewdlDewdl

Copy link
Copy Markdown
Contributor

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

  • Quality gate: all checks pass
  • Behavior: dispatcher timeouts now surface the real error (e.g., "Chrome CDP websocket not reachable after start") instead of the misleading "Can't reach the browser control service"

Fixes #39007

…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-apps

greptile-apps Bot commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes misleading error messages in fetchBrowserJson by preserving the original dispatcher error instead of wrapping it as "Can't reach the OpenClaw browser control service" — a message that was accurate for network failures but confusing for in-process operation timeouts (e.g., Chrome CDP not becoming ready in time).

Key changes:

  • Adds an isDispatcherPath boolean flag set after the isAbsoluteHttp branch — correctly scoping to the in-process dispatcher path only.
  • In the catch block, re-throws the raw error when on a dispatcher path, bypassing enhanceBrowserFetchError.

Issue found:

  • The bypass is too broad: it also removes the modelHint appended by enhanceBrowserFetchError, which explicitly instructs the LLM not to retry the browser tool. The codebase comment at lines 109–111 documents this as a deliberate guard against infinite LLM retry loops. Silently dropping this hint for all dispatcher-path errors (timeouts, "browser control disabled", CDP failures, etc.) reintroduces the risk of LLMs looping on browser tool failures. A targeted fix — dropping only the "Can't reach…" prefix while preserving the model hint — would address the original bug without this regression.

Confidence Score: 3/5

  • The fix correctly surfaces dispatcher errors but inadvertently removes the model retry-loop guard for all dispatcher-path failures.
  • The change is small and targeted, and the core intent (not wrapping dispatcher errors as network unreachability) is correct. However, bypassing enhanceBrowserFetchError entirely also drops the modelHint — a guard explicitly put in place to prevent LLMs from retrying the browser tool indefinitely on failure. This is a meaningful behavioral regression that could surface as production issues with LLM clients.
  • src/browser/client-fetch.ts — specifically the catch block starting at line 252, where the dispatcher-path early re-throw bypasses the model retry-loop hint.

Last reviewed commit: 400900a

Comment on lines +256 to +260
// For dispatcher paths, timeout/abort errors indicate service operation failure,
// not network unreachability. Preserve the original error for clearer diagnosis.
if (isDispatcherPath) {
throw err;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in commit 874f5ad — preserved dispatcher error context while appending the browser no-retry hint to prevent retry loops.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +258 to +259
if (isDispatcherPath) {
throw err;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in commit 874f5ad — preserved dispatcher error context while appending the browser no-retry hint to prevent retry loops.

steipete added a commit that referenced this pull request Mar 7, 2026
@steipete

steipete commented Mar 7, 2026 •

Copy link
Copy Markdown
Contributor

Landed on main in 9b4a114eb2927df03b0cb7937f4b90b7e9d481e3.

What we changed while landing:

  • kept your dispatcher-path clarity fix
  • added anti-loop hardening so dispatcher errors still include explicit model no-retry guidance
  • added regression tests for dispatcher error preservation + absolute-URL wrapping behavior
  • added changelog entry in 2026.3.7 fixes

Source commit reviewed: 400900a5ed9e13879bbb470c5deb413c35873b89.

Thanks @NewdlDewdl.

@steipete steipete closed this Mar 7, 2026
vincentkoc pushed a commit to BryanTegomoh/openclaw-contrib that referenced this pull request Mar 8, 2026
openperf pushed a commit to openperf/moltbot that referenced this pull request Mar 8, 2026
mcaxtr pushed a commit to mcaxtr/openclaw that referenced this pull request Mar 8, 2026
GordonSH-oss pushed a commit to GordonSH-oss/openclaw that referenced this pull request Mar 9, 2026
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 21, 2026
Landed from openclaw#39090 by @NewdlDewdl.

Co-authored-by: NewdlDewdl <[email protected]>
(cherry picked from commit 9b4a114)
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 21, 2026
Landed from openclaw#39090 by @NewdlDewdl.

Co-authored-by: NewdlDewdl <[email protected]>
(cherry picked from commit 9b4a114)
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Browser tool times out reaching browser control service though service is listening

3 participants