Skip to content

fix(nextcloud-talk): add fetch timeout to send and reaction POST calls - #41535

Closed
hclsys wants to merge 2 commits into
openclaw:mainfrom
hclsys:fix/nextcloud-talk-fetch-timeout
Closed

hclsys wants to merge 2 commits into
openclaw:mainfrom
hclsys:fix/nextcloud-talk-fetch-timeout

Conversation

@hclsys

@hclsys hclsys commented Mar 9, 2026

Copy link
Copy Markdown

Summary

Test plan

  • Verify CI passes
  • Confirm no existing tests break
  • Manual: stalled Nextcloud server now times out after 30s instead of hanging forever

lobster-biscuit

Both `sendMessageNextcloudTalk()` and `sendReactionNextcloudTalk()` in
`extensions/nextcloud-talk/src/send.ts` call `fetch()` without a
timeout, so a stalled Nextcloud server can hang the bot process
indefinitely.

Add `AbortSignal.timeout(30_000)` to both POST calls. Uses 30s (vs
10s for read-only fetches) since message delivery may involve server-
side processing.

lobster-biscuit

Signed-off-by: Chenglun Hu <[email protected]>
Signed-off-by: HCL <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added channel: nextcloud-talk Channel integration: nextcloud-talk size: XS labels Mar 9, 2026
@greptile-apps

greptile-apps Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds AbortSignal.timeout(30_000) to the two outbound fetch() POST calls in the Nextcloud Talk extension (sendMessageNextcloudTalk and sendReactionNextcloudTalk), preventing the bot process from hanging indefinitely when the Nextcloud server stalls. The change is minimal, correct, and consistent with the pattern used in earlier PRs for read calls.

  • AbortSignal.timeout(30_000) added to sendMessageNextcloudTalk fetch (line 117)
  • AbortSignal.timeout(30_000) added to sendReactionNextcloudTalk fetch (line 209)
  • One style-level concern: when the timeout fires, a raw DOMException (TimeoutError) propagates to callers rather than a descriptive error message — unlike the named HTTP-error handling already present in the same functions. Wrapping the fetch() in a try/catch to re-throw with a friendlier message would improve observability.

Confidence Score: 4/5

  • Safe to merge — the change is a minimal, correct addition of fetch timeouts with no functional regressions.
  • The two-line diff is straightforward and the approach is well-established. The only concern is that the TimeoutError (DOMException) thrown by AbortSignal.timeout() is not caught and re-thrown with a descriptive message, which is an inconsistency with the HTTP error handling in the same functions. This is a style-level issue and does not affect correctness or safety.
  • No files require special attention beyond the style suggestion on extensions/nextcloud-talk/src/send.ts.

Last reviewed commit: 414e7c8

Comment thread extensions/nextcloud-talk/src/send.ts Outdated
Comment on lines 117 to 118
signal: AbortSignal.timeout(30_000),
});

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.

TimeoutError propagates as raw DOMException

When AbortSignal.timeout() fires, it throws a DOMException with name === 'TimeoutError' rather than an AbortError. Because neither sendMessageNextcloudTalk nor sendReactionNextcloudTalk wraps the fetch() call in a try/catch, callers will receive an opaque DOMException: The operation was aborted due to timeout instead of a descriptive error message.

Consider catching it and re-throwing with a clearer message, consistent with how HTTP error codes are handled below:

  let response: Response;
  try {
    response = await fetch(url, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "OCS-APIRequest": "true",
        "X-Nextcloud-Talk-Bot-Random": random,
        "X-Nextcloud-Talk-Bot-Signature": signature,
      },
      body: bodyStr,
      signal: AbortSignal.timeout(30_000),
    });
  } catch (err) {
    if (err instanceof DOMException && err.name === "TimeoutError") {
      throw new Error("Nextcloud Talk send timed out after 30s");
    }
    throw err;
  }

The same applies to the sendReactionNextcloudTalk call at line 209.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/nextcloud-talk/src/send.ts
Line: 117-118

Comment:
**TimeoutError propagates as raw DOMException**

When `AbortSignal.timeout()` fires, it throws a `DOMException` with `name === 'TimeoutError'` rather than an `AbortError`. Because neither `sendMessageNextcloudTalk` nor `sendReactionNextcloudTalk` wraps the `fetch()` call in a try/catch, callers will receive an opaque `DOMException: The operation was aborted due to timeout` instead of a descriptive error message.

Consider catching it and re-throwing with a clearer message, consistent with how HTTP error codes are handled below:

```ts
  let response: Response;
  try {
    response = await fetch(url, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "OCS-APIRequest": "true",
        "X-Nextcloud-Talk-Bot-Random": random,
        "X-Nextcloud-Talk-Bot-Signature": signature,
      },
      body: bodyStr,
      signal: AbortSignal.timeout(30_000),
    });
  } catch (err) {
    if (err instanceof DOMException && err.name === "TimeoutError") {
      throw new Error("Nextcloud Talk send timed out after 30s");
    }
    throw err;
  }
```

The same applies to the `sendReactionNextcloudTalk` call at line 209.

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

…errors

When AbortSignal.timeout fires, the raw DOMException propagates with a
cryptic message. Wrap both fetch calls in try/catch to re-throw with a
descriptive "Nextcloud Talk send/reaction failed:" prefix, consistent
with the existing HTTP error handling in the same functions.

Signed-off-by: Chenglun Hu <[email protected]>
Signed-off-by: HCL <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: nextcloud-talk Channel integration: nextcloud-talk size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant