fix(web): stop SSE reconnect loop on 4xx errors
A revoked api key or missing topic returned by GET /v1/.../stream used to throw inside the catch and bounce through the backoff loop forever. Now any 4xx response terminates the loop and surfaces the status + body in the panel error so the user sees the real cause. 5xx and network errors still reconnect. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -243,6 +243,15 @@ export function TopicChatPanel({
|
|||||||
cache: "no-store",
|
cache: "no-store",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
// 4xx is terminal — auth invalid, key revoked, topic gone.
|
||||||
|
// Reconnecting won't fix any of those, so surface the error
|
||||||
|
// and stop. 5xx and network errors fall through to backoff.
|
||||||
|
if (res.status >= 400 && res.status < 500) {
|
||||||
|
const body = await res.text().catch(() => "");
|
||||||
|
setError(`stream halted: ${res.status} ${body.slice(0, 200)}`);
|
||||||
|
setStreamState("stopped");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!res.ok || !res.body) {
|
if (!res.ok || !res.body) {
|
||||||
throw new Error(`stream open failed: ${res.status}`);
|
throw new Error(`stream open failed: ${res.status}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user