Skip to content

Commit b389979

Browse files
committed
Remove arbitrary timeouts from chat, keep proper error handling
1 parent aea9456 commit b389979

2 files changed

Lines changed: 1 addition & 15 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
### 1.11.3: 2026-03-28
22

33
* Fix chat loading indicator stuck forever when returning to chat
4-
* Add 10s timeout on initial message load, 120s timeout on AI response
5-
* Gracefully handle aborted/failed message fetches
64

75
### 1.11.2: 2026-03-28
86

src/components/chat/chat-interface.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,9 @@ export function ChatInterface() {
6666
if (d.user) setCurrentUser(d.user.display_name || d.user.email);
6767
}).catch(() => {});
6868

69-
const controller = new AbortController();
70-
const loadTimeout = setTimeout(() => { controller.abort(); setInitialLoading(false); }, 10000);
71-
72-
fetch("/api/chat/messages", { signal: controller.signal })
69+
fetch("/api/chat/messages")
7370
.then((r) => r.json())
7471
.then((data) => {
75-
clearTimeout(loadTimeout);
7672
if (data.messages?.length > 0) {
7773
console.info("[chat] Loaded", data.messages.length, "messages, hasOlder:", data.hasOlder);
7874
const msgs = data.messages.map((m: { id: number; role: string; content: string; sender?: string; image_thumb?: string }) => ({
@@ -102,7 +98,6 @@ export function ChatInterface() {
10298
}
10399
})
104100
.catch(() => {
105-
clearTimeout(loadTimeout);
106101
setMessages([{ id: "greeting", role: "assistant", content: t.chat.greeting }]);
107102
})
108103
.finally(() => {
@@ -261,19 +256,13 @@ export function ChatInterface() {
261256
setChatImageType("");
262257
}
263258

264-
const aiTimeout = setTimeout(() => {
265-
console.warn("[chat] AI request timed out after 120s");
266-
setLoading(false);
267-
}, 120000);
268-
269259
fetch("/api/chat", {
270260
method: "POST",
271261
headers: { "Content-Type": "application/json" },
272262
body: JSON.stringify(chatBody),
273263
})
274264
.then((r) => r.json())
275265
.then((data) => {
276-
clearTimeout(aiTimeout);
277266
// Add from fetch response if SSE hasn't delivered it yet (dedup prevents doubles)
278267
if (data.message) {
279268
setMessages((prev) => {
@@ -285,7 +274,6 @@ export function ChatInterface() {
285274
}
286275
})
287276
.catch(() => {
288-
clearTimeout(aiTimeout);
289277
console.warn("[chat] AI request failed");
290278
setLoading(false);
291279
});

0 commit comments

Comments
 (0)