← Back to PRs

#9407: fix(usage): catch AbortError in withTimeout to prevent CLI crash

by zenchantlive open 2026-02-05 05:59 View on GitHub →
stale
## Problem Running `openclaw status --usage --json` crashes with: ``` AbortError: This operation was aborted ``` When a provider fetch times out, the AbortError from the AbortController propagates up and crashes the CLI instead of returning the fallback error value. ## Solution Catch `AbortError` in `withTimeout()` and return the fallback instead of crashing. ## Changes - `src/infra/provider-usage.shared.ts`: Added try/catch to handle AbortError in the withTimeout function Fixes #9385 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates `src/infra/provider-usage.shared.ts` to make `withTimeout()` resilient to abort-driven failures by catching `AbortError` (e.g., from `AbortController`-backed fetch timeouts) and returning the provided fallback value instead of letting the error propagate and crash the CLI. The change is localized to the shared provider-usage timeout helper that wraps provider fetch work; callers that use `withTimeout()` now get a stable fallback result when the underlying request is aborted. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - The change is small, localized, and correctly narrows handling to AbortError while preserving existing behavior for all other errors; it also maintains timer cleanup in the finally block. - No files require special attention <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs