Skip to content

lib/api.ts and sse.ts use string-based error classification (drop HTTP status); streamSSE has no timeout #192

@Jose-Gael-Cruz-Lopez

Description

@Jose-Gael-Cruz-Lopez

Severity: Low
Labels: tech-debt, frontend, P3
Location: frontend/src/lib/api.ts:15-29, frontend/src/lib/sse.ts:33-37; consumer frontend/src/components/ErrorBoundary.tsx:44-53

Description

Both the JSON client and the SSE consumer discard the numeric HTTP status and throw a plain Error whose only signal is a stringified body; ErrorFallback then re-derives intent by substring-matching the message. This is brittle — 403/429/500 all collapse to a generic branch, and a body containing "session" misclassifies as "session expired." streamSSE also attaches no AbortController/timeout, so a stalled stream hangs indefinitely.

Suggested fix

Throw a typed class ApiError extends Error { status: number } from fetchJSON and streamSSE; branch ErrorFallback on status. Add an AbortController with an idle timeout to streamSSE.

Acceptance criteria

  • Error UI branches on HTTP status, not substrings; a stalled SSE stream aborts after a timeout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priority / polishfrontendFrontend / UItech-debtCleanup / maintainability

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions