#9407: fix(usage): catch AbortError in withTimeout to prevent CLI crash
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
#11874: fix: handle fetch rejections in provider usage withTimeout
by Zjianru · 2026-02-08
82.0%
#6143: fix(agents): handle AbortError from activeSession.abort() on timeout
by Glucksberg · 2026-02-01
74.5%
#7247: fix(telegram): abort stale getUpdates connections after long-poll t...
by JanderV · 2026-02-02
73.4%
#19284: fix(delivery): treat AbortErrors as failures for retry
by EdGuan · 2026-02-17
73.4%
#7810: fix: add fetch timeouts to prevent memory indexing hangs (#4370)
by Kaizen-79 · 2026-02-03
72.2%
#23745: fix(resilience): add timeout to unguarded fetch calls in browser su...
by kevinWangSheng · 2026-02-22
72.1%
#20946: fix: skip auth cooldown on timeout (not an auth failure)
by austenstone · 2026-02-19
71.7%
#10636: fix: setTimeout integer overflow causing server crash
by devmangel · 2026-02-06
71.5%
#6059: fix #6044
by vivganes · 2026-02-01
71.4%
#11101: fix: handle AbortError and WebSocket 1006 in unhandled rejection ha...
by Nipurn123 · 2026-02-07
71.2%