Skip to content

fix: increase upload timeout and wrap non-Error abort rejections#534

Open
taylorhou wants to merge 1 commit intoopenclaw:mainfrom
taylorhou:fix/publish-timeout-upload
Open

fix: increase upload timeout and wrap non-Error abort rejections#534
taylorhou wants to merge 1 commit intoopenclaw:mainfrom
taylorhou:fix/publish-timeout-upload

Conversation

@taylorhou
Copy link

Problem

Fixes #533

clawhub publish consistently times out with:

✖ Non-error was thrown: "Timeout". You should only throw errors.

Two root causes:

1. Timeout too short for form uploads

REQUEST_TIMEOUT_MS (15s) is applied uniformly to all requests including multipart form uploads in apiRequestForm. Uploading skill files to the server can easily exceed 15s depending on skill size and server-side processing time.

2. Non-Error abort rejections not re-wrapped

In some Node.js/undici versions, controller.abort(reason) causes fetch to reject with the raw reason value rather than wrapping it. If the reason is not an Error instance (or gets lost in propagation), pRetry surfaces the unhelpful Non-error was thrown message instead of the underlying cause.

Fix

  1. Added UPLOAD_TIMEOUT_MS = 120_000 (2 min) and applied it to both the Node fetchWithTimeout path and the Bun/curl --max-time path in apiRequestForm / fetchJsonFormViaCurl.
  2. In fetchWithTimeout, wrap any non-Error rejection in a new Error so pRetry always receives a proper Error instance.
  3. Updated the abort reason message to include the timeout duration for easier debugging.

Testing

Verified locally that clawhub whoami still works and the timeout constants are wired correctly.

…ance

The publish command was timing out because REQUEST_TIMEOUT_MS (15s) was
used for all requests including multipart form uploads, which can take
much longer depending on skill size and server processing time.

Two fixes:
1. Add UPLOAD_TIMEOUT_MS (120s) and use it in apiRequestForm and the
   corresponding curl code path for form uploads.
2. Wrap non-Error fetch rejections in fetchWithTimeout so pRetry always
   receives a proper Error instance. In some Node/undici versions,
   AbortController.abort(reason) can cause fetch to reject with the raw
   reason value. If that value is not an Error, pRetry surfaces the
   unhelpful message 'Non-error was thrown: Timeout' instead of a
   meaningful error.

Fixes openclaw#533
@vercel
Copy link
Contributor

vercel bot commented Feb 26, 2026

Someone is attempting to deploy a commit to the Amantus Machina Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

Increased upload timeout from 15s to 120s and ensured abort rejections are always wrapped in proper Error instances. The changes correctly address the two root causes of clawhub publish timeouts:

  • Added UPLOAD_TIMEOUT_MS (120s) constant applied consistently to both Node.js (fetchWithTimeout) and Bun/curl (--max-time) code paths in form upload functions
  • Enhanced fetchWithTimeout to wrap non-Error rejections, ensuring pRetry always receives Error instances with meaningful messages
  • Improved error messages to include timeout duration for easier debugging

The implementation is clean and follows existing patterns. However, the improved error message format (Request timed out after ${timeoutMs}ms instead of Timeout) will cause test failures in http.test.ts at lines 264 and 346. These test assertions need to be updated to match the new format.

Confidence Score: 4/5

  • Safe to merge after updating test assertions to match the new error message format
  • The core logic is sound and properly addresses both timeout and error wrapping issues across all code paths. Error handling is defensive and consistent. Score reduced by one point due to breaking test changes - the improved error message breaks exact string assertions in two test cases (lines 264 and 346 in http.test.ts). This is a trivial fix but must be addressed before merge.
  • Verify that http.test.ts is updated to match the new timeout error message format before merging

Last reviewed commit: 938998d

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

// Ensure we always throw a proper Error instance. Some Node/undici versions
// propagate the abort reason as-is; if it is not an Error, pRetry will
// surface "Non-error was thrown" instead of a meaningful message.
controller.abort(new Error(`Request timed out after ${timeoutMs}ms`))
Copy link
Contributor

Choose a reason for hiding this comment

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

Updated timeout error message will break existing tests in http.test.ts (lines 264 and 346) that expect .message to be exactly "Timeout". Update test assertions to match the new format:

Suggested change
controller.abort(new Error(`Request timed out after ${timeoutMs}ms`))
controller.abort(new Error(`Request timed out after ${timeoutMs}ms`))

Then update http.test.ts:

// Line 264
expect((caught as Error).message).toContain('timed out')

// Line 346  
expect((caught as Error).message).toContain('timed out')
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/clawdhub/src/http.ts
Line: 220

Comment:
Updated timeout error message will break existing tests in `http.test.ts` (lines 264 and 346) that expect `.message` to be exactly `"Timeout"`. Update test assertions to match the new format:

```suggestion
    controller.abort(new Error(`Request timed out after ${timeoutMs}ms`))
```

Then update `http.test.ts`:
```typescript
// Line 264
expect((caught as Error).message).toContain('timed out')

// Line 346  
expect((caught as Error).message).toContain('timed out')
```

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

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

Tests expect error message 'Timeout' but the code produces 'Request timed out after

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clawhub publish times out on upload despite successful auth

1 participant