Skip to content

Commit f008295

Browse files
justin808claude
andcommitted
Add fetch timeout to RSC CommentsFeed to prevent indefinite hangs
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f55dcc2 commit f008295

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

client/app/bundles/server-components/components/CommentsFeed.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ async function CommentsFeed() {
3636
try {
3737
// Fetch comments directly from the Rails API — no client-side fetch needed
3838
const baseUrl = resolveRailsBaseUrl();
39-
const response = await fetch(`${baseUrl}/comments.json`);
39+
const controller = new AbortController();
40+
const timeoutId = setTimeout(() => controller.abort(), 5000);
41+
const response = await fetch(`${baseUrl}/comments.json`, { signal: controller.signal });
42+
clearTimeout(timeoutId);
4043
if (!response.ok) {
4144
throw new Error(`Failed to fetch comments: ${response.status} ${response.statusText}`);
4245
}

0 commit comments

Comments
 (0)