Repository navigation
Conversation
sendMessageNextcloudTalk() and sendReactionNextcloudTalk() POST to
self-hosted Nextcloud instances with no timeout. A slow or
unresponsive server would stall the outbound message pipeline
indefinitely.
Add a 30-second AbortSignal.timeout to both fetch calls (outbound
sends to self-hosted servers need a longer timeout than API metadata
calls). Both are wrapped in try/catch with { cause: err }.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: HCL <[email protected]>
Greptile SummaryThis PR adds a 30-second
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/nextcloud-talk/src/send.ts
Line: 115-207
Comment:
**Duplicated magic timeout constant**
The value `30_000` appears in both `sendMessageNextcloudTalk` and `sendReactionNextcloudTalk`. If the timeout needs to be tuned in the future, both sites must be updated in sync. Extracting it as a module-level named constant avoids that drift.
```suggestion
const NEXTCLOUD_TALK_FETCH_TIMEOUT_MS = 30_000;
```
Then replace both occurrences of `AbortSignal.timeout(30_000)` with `AbortSignal.timeout(NEXTCLOUD_TALK_FETCH_TIMEOUT_MS)`.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/nextcloud-talk/src/send.ts
Line: 117-122
Comment:
**Timeout errors are not distinguished from other fetch errors**
When `AbortSignal.timeout(30_000)` fires it throws a `DOMException` with `name === "TimeoutError"`. The current catch block wraps every fetch-level error under the same generic message (`"Nextcloud Talk send failed: The operation was aborted due to timeout"`), making it harder for callers or on-call engineers to tell at a glance whether the server was unreachable vs. just slow.
Consider explicitly handling the timeout case:
```suggestion
} catch (err) {
if (err instanceof Error && err.name === "TimeoutError") {
throw new Error(
`Nextcloud Talk send timed out after ${NEXTCLOUD_TALK_FETCH_TIMEOUT_MS / 1000}s`,
{ cause: err },
);
}
throw new Error(
`Nextcloud Talk send failed: ${err instanceof Error ? err.message : String(err)}`,
{ cause: err },
);
}
```
The same pattern applies to the catch block in `sendReactionNextcloudTalk` (line ~209).
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 49067bb |
| @@ -184,16 +193,25 @@ export async function sendReactionNextcloudTalk( | |||
|
|
|||
| const url = `${baseUrl}/ocs/v2.php/apps/spreed/api/v1/bot/${normalizedToken}/reaction/${messageId}`; | |||
|
|
|||
| const 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, | |||
| }); | |||
| 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, | |||
| signal: AbortSignal.timeout(30_000), | |||
There was a problem hiding this comment.
Duplicated magic timeout constant
The value 30_000 appears in both sendMessageNextcloudTalk and sendReactionNextcloudTalk. If the timeout needs to be tuned in the future, both sites must be updated in sync. Extracting it as a module-level named constant avoids that drift.
| const NEXTCLOUD_TALK_FETCH_TIMEOUT_MS = 30_000; |
Then replace both occurrences of AbortSignal.timeout(30_000) with AbortSignal.timeout(NEXTCLOUD_TALK_FETCH_TIMEOUT_MS).
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/nextcloud-talk/src/send.ts
Line: 115-207
Comment:
**Duplicated magic timeout constant**
The value `30_000` appears in both `sendMessageNextcloudTalk` and `sendReactionNextcloudTalk`. If the timeout needs to be tuned in the future, both sites must be updated in sync. Extracting it as a module-level named constant avoids that drift.
```suggestion
const NEXTCLOUD_TALK_FETCH_TIMEOUT_MS = 30_000;
```
Then replace both occurrences of `AbortSignal.timeout(30_000)` with `AbortSignal.timeout(NEXTCLOUD_TALK_FETCH_TIMEOUT_MS)`.
How can I resolve this? If you propose a fix, please make it concise.| } catch (err) { | ||
| throw new Error( | ||
| `Nextcloud Talk send failed: ${err instanceof Error ? err.message : String(err)}`, | ||
| { cause: err }, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Timeout errors are not distinguished from other fetch errors
When AbortSignal.timeout(30_000) fires it throws a DOMException with name === "TimeoutError". The current catch block wraps every fetch-level error under the same generic message ("Nextcloud Talk send failed: The operation was aborted due to timeout"), making it harder for callers or on-call engineers to tell at a glance whether the server was unreachable vs. just slow.
Consider explicitly handling the timeout case:
| } catch (err) { | |
| throw new Error( | |
| `Nextcloud Talk send failed: ${err instanceof Error ? err.message : String(err)}`, | |
| { cause: err }, | |
| ); | |
| } | |
| } catch (err) { | |
| if (err instanceof Error && err.name === "TimeoutError") { | |
| throw new Error( | |
| `Nextcloud Talk send timed out after ${NEXTCLOUD_TALK_FETCH_TIMEOUT_MS / 1000}s`, | |
| { cause: err }, | |
| ); | |
| } | |
| throw new Error( | |
| `Nextcloud Talk send failed: ${err instanceof Error ? err.message : String(err)}`, | |
| { cause: err }, | |
| ); | |
| } |
The same pattern applies to the catch block in sendReactionNextcloudTalk (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-122
Comment:
**Timeout errors are not distinguished from other fetch errors**
When `AbortSignal.timeout(30_000)` fires it throws a `DOMException` with `name === "TimeoutError"`. The current catch block wraps every fetch-level error under the same generic message (`"Nextcloud Talk send failed: The operation was aborted due to timeout"`), making it harder for callers or on-call engineers to tell at a glance whether the server was unreachable vs. just slow.
Consider explicitly handling the timeout case:
```suggestion
} catch (err) {
if (err instanceof Error && err.name === "TimeoutError") {
throw new Error(
`Nextcloud Talk send timed out after ${NEXTCLOUD_TALK_FETCH_TIMEOUT_MS / 1000}s`,
{ cause: err },
);
}
throw new Error(
`Nextcloud Talk send failed: ${err instanceof Error ? err.message : String(err)}`,
{ cause: err },
);
}
```
The same pattern applies to the catch block in `sendReactionNextcloudTalk` (line ~209).
How can I resolve this? If you propose a fix, please make it concise.
lobster-biscuit
Problem
sendMessageNextcloudTalk()andsendReactionNextcloudTalk()POST to self-hosted Nextcloud instances with no timeout. A slow or unresponsive server would stall the outbound message pipeline indefinitely.Self-hosted instances are particularly prone to this since they often lack the CDN-level timeouts that cloud services provide.
Solution
Add a 30-second
AbortSignal.timeoutto both fetch calls. Both are wrapped in try/catch with{ cause: err }to preserve the cause chain.30 seconds is chosen because outbound sends to self-hosted servers may be slower than typical API metadata calls, but should not take longer than half a minute.
Changes
extensions/nextcloud-talk/src/send.ts— addAbortSignal.timeout(30_000)to bothsendMessageNextcloudTalk()andsendReactionNextcloudTalk()Test plan
🤖 Generated with Claude Code