Skip to content

fix(browser): keep local action timeouts specific instead of service outage - #38852

Closed
SergioChan wants to merge 2 commits into
openclaw:mainfrom
SergioChan:fix-browser-timeout-error-mapping-38844
Closed

SergioChan wants to merge 2 commits into
openclaw:mainfrom
SergioChan:fix-browser-timeout-error-mapping-38844

Conversation

@SergioChan

Copy link
Copy Markdown

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: fetchBrowserJson mapped local browser action timeouts to a transport outage error (Can't reach the OpenClaw browser control service), which is misleading when the local dispatcher is alive but the action itself timed out.
  • Why it matters: stale refs / long-running file chooser actions can look like gateway failures, pushing users and agents toward incorrect remediation (restart gateway) and retry loops.
  • What changed: split timeout detection from generic fetch errors and return a local-action-specific timeout message for relative/local browser control routes.
  • What changed: added client-fetch.timeout-errors.test.ts to lock in this behavior.
  • What did NOT change (scope boundary): no change to route dispatch semantics, no change to timeout defaults, and no automatic retry behavior added.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

Local browser action timeouts (relative routes) now report as action timeouts while the control service is reachable, instead of incorrectly reporting browser-control-service outage.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: Linux (WSL2)
  • Runtime/container: local Node + pnpm
  • Model/provider: n/a
  • Integration/channel (if any): browser control local dispatcher path
  • Relevant config (redacted): default local browser control path

Steps

  1. Trigger fetchBrowserJson on a local/relative browser route where dispatcher throws a timeout-like error.
  2. Observe returned error text.
  3. Run targeted test: pnpm exec vitest run src/browser/client-fetch.timeout-errors.test.ts.

Expected

  • Error stays action-specific for local dispatch timeout and does not claim browser control service outage.

Actual

  • Test passes and confirms message contains: Browser action timed out after ... while the local browser control service remained reachable.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: local dispatch timeout now maps to local-action timeout message.
  • Edge cases checked: absolute HTTP URL timeout path still uses service-unreachable timeout messaging (unchanged by test scope, code path retained).
  • What you did not verify: full end-to-end browser chooser flow in live UI.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert commit f01ae55.
  • Files/config to restore: src/browser/client-fetch.ts, remove src/browser/client-fetch.timeout-errors.test.ts.
  • Known bad symptoms reviewers should watch for: timeout errors reverting to transport-outage wording for local routes.

Risks and Mitigations

  • Risk: wording change may affect any tests or tooling that match old timeout text.
    • Mitigation: change is scoped to local timeout branch only; added dedicated test for new intended wording.

@greptile-apps

greptile-apps Bot commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR correctly fixes the mis-classification of local browser action timeouts as a transport/service-outage error by splitting the enhanceBrowserFetchError path based on whether the URL is local or remote. The refactoring of timeout detection into looksLikeTimeoutError and raw error formatting into errorMessage is clean, and the new test file locks in the intended behavior for the local-timeout branch.

Key finding:

  • Contradictory retry instructions (logic issue): The local timeout error message simultaneously says "try...retry with a stable ref" (recovery hint) and "Do NOT retry the browser tool" (model hint). It also claims the service remained reachable but then says the browser is currently unavailable. Since this is a recoverable action timeout, the modelHint should clarify that retry is blocked only when parameters remain unchanged, allowing agents to retry with actionable changes (stable ref, increased timeout).

Confidence Score: 3/5

  • Safe to merge after clarifying the contradictory retry instructions in the local timeout error message.
  • The core fix is correct and well-tested. However, the local-timeout branch reuses a service-outage modelHint that contradicts the recovery hint and claims the browser is unavailable when the message itself establishes that the service remained reachable. This logical inconsistency could confuse LLM agents and partially defeat the PR's goal of preventing retry loops. The fix is straightforward (revise the modelHint for the local-timeout case) but should be completed before merging.
  • src/browser/client-fetch.ts — specifically the local timeout error message (lines 130–132) needs the modelHint revised to allow retries with changed parameters.

Last reviewed commit: f01ae55

Comment thread src/browser/client-fetch.ts Outdated
Comment on lines +130 to +132
`Browser action timed out after ${timeoutMs}ms while the local browser control service remained reachable. Try a fresh snapshot and retry with a stable ref, or increase timeoutMs if the action is expected to take longer. ${modelHint}`,
);
}

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.

Contradictory retry instructions in local timeout message

The local timeout error message appends a modelHint designed for service-outage scenarios, creating factually contradictory guidance:

  • Message says: "service remained reachable" + "Try...retry with a stable ref"
  • But also says: "Do NOT retry the browser tool" + "browser is currently unavailable"

Since this error indicates a recoverable action timeout (not a service outage), the modelHint should clarify that retry is acceptable when parameters change:

Suggested change
`Browser action timed out after ${timeoutMs}ms while the local browser control service remained reachable. Try a fresh snapshot and retry with a stable ref, or increase timeoutMs if the action is expected to take longer. ${modelHint}`,
);
}
return new Error(
`Browser action timed out after ${timeoutMs}ms while the local browser control service remained reachable. ` +
`Try a fresh snapshot and retry with a stable ref, or increase timeoutMs if the action is expected to take longer. ` +
`Do NOT retry the browser tool with the same parameters — it will keep failing. If the action cannot be completed, use an alternative approach or inform the user.`,
);

This clarifies that retry is blocked only when parameters are unchanged, while allowing agents to retry with actionable changes.

Rule Used: CLAUDE.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/browser/client-fetch.ts
Line: 130-132

Comment:
**Contradictory retry instructions in local timeout message**

The local timeout error message appends a `modelHint` designed for service-outage scenarios, creating factually contradictory guidance:

- Message says: "service remained reachable" + "Try...retry with a stable ref"  
- But also says: "Do NOT retry the browser tool" + "browser is currently unavailable"

Since this error indicates a recoverable action timeout (not a service outage), the `modelHint` should clarify that retry is acceptable when parameters change:

```suggestion
      return new Error(
        `Browser action timed out after ${timeoutMs}ms while the local browser control service remained reachable. ` +
          `Try a fresh snapshot and retry with a stable ref, or increase timeoutMs if the action is expected to take longer. ` +
          `Do NOT retry the browser tool with the same parameters — it will keep failing. If the action cannot be completed, use an alternative approach or inform the user.`,
      );
```

This clarifies that retry is blocked only when parameters are unchanged, while allowing agents to retry with actionable changes.

**Rule Used:** CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))

How can I resolve this? If you propose a fix, please make it concise.

@SergioChan

Copy link
Copy Markdown
Author

Thanks for the catch — addressed in 2a953fd.\n\n### What changed\n- Split model guidance so local action timeouts no longer reuse the service-outage wording.\n- Local timeout guidance now explicitly allows retry only after changing parameters (fresh refs / higher timeout), and avoids saying the browser service is unavailable.\n- Service-outage guidance remains strict about not repeating unchanged retries.\n\n### Validation\n-
�[1m�[46m RUN �[49m�[22m �[36mv4.0.18 �[39m�[90m/home/chen/openclaw�[39m

@SergioChan

Copy link
Copy Markdown
Author

Correction: validation run was pnpm vitest run src/browser/client-fetch.timeout-errors.test.ts (executed locally and passing before push).

@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: 2a953fdd6e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +128 to +131
if (looksLikeTimeoutError(err)) {
if (isLocal) {
return new Error(
`Browser action timed out after ${timeoutMs}ms while the local browser control service remained reachable. Try a fresh snapshot and retry with a stable ref, or increase timeoutMs if the action is expected to take longer. ${localTimeoutModelHint}`,

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.

P2 Badge Preserve abort errors instead of rewording as local timeouts

For relative browser routes, this branch rewrites every looksLikeTimeoutError into "Browser action timed out ... service remained reachable", but looksLikeTimeoutError also matches aborts (abort/aborted). In fetchBrowserJson, an upstream AbortSignal cancellation flows into this path, so caller-initiated cancels get misreported as timeouts with retry advice, which is misleading and can trigger unnecessary retries when the operation was intentionally canceled rather than timing out.

Useful? React with 👍 / 👎.

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 upload/file chooser flow is flaky and can misreport stale-click failures as browser control timeouts

1 participant