Skip to content

fix(web): improve frontend error handling#1498

Merged
Haz3-jolt merged 1 commit into
BlazeUp-AI:mainfrom
VishnuM049:fix/frontend-error-handling
Jun 23, 2026
Merged

fix(web): improve frontend error handling#1498
Haz3-jolt merged 1 commit into
BlazeUp-AI:mainfrom
VishnuM049:fix/frontend-error-handling

Conversation

@VishnuM049

@VishnuM049 VishnuM049 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Purpose / Description

Fixes the reported issue where the frontend incorrectly clears the user's session and redirects to login when the API is temporarily unreachable (network drop, server restart, flaky connection). Also adds a global error boundary and improves error feedback across multiple pages.

Fixes

  • Fixes session being cleared on transient network errors

Approach

Core fix: _tryRefreshToken now returns "ok" | "rejected" | "network_error" instead of a boolean. The auth guard and request wrapper only clear the session on "rejected" (server explicitly said no), not on "network_error" (fetch threw TypeError because server was unreachable).

Error boundary: Class component wrapping the app root. Catches render errors and shows "Something went wrong - Reload" instead of white-screening.

Error states on data pages: Exec dashboard tabs, leaderboard, registry home now check isError from React Query and show error messages instead of rendering with undefined data (which produced misleading zeroes).

Silent failures surfaced: Cost baselines save, audit log export, and admin settings load all now show toasts on failure.

API client hardening: Raw error messages (tracebacks, long plaintext) are sanitized before reaching toasts. Insights HTML export now retries with a fresh token on 401.

How Has This Been Tested?

  • TypeScript compiles without errors
  • Killed API process while logged in (same tab) - app stays logged in, pages show error states, no redirect to login
  • Restarted API - app resumes normally, data loads on retry
  • New tab with API down - correctly shows login (can't exchange refresh token without server, this is expected)

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)

AI Assistance

  • Yes(Please Specify the tool): Claude Code
  • Was the generated code manually reviewed and tested?

@github-actions github-actions Bot added the web Pull request touches web frontend code label Jun 22, 2026
@VishnuM049 VishnuM049 marked this pull request as draft June 22, 2026 22:59
@VishnuM049 VishnuM049 force-pushed the fix/frontend-error-handling branch from 4b70b9b to 11ebec8 Compare June 22, 2026 23:12
- Add React ErrorBoundary at app root (prevents white-screen crashes)
- Auth guard: don't clear session on network errors (TypeError/offline)
- Token refresh: only nuke session when online (not on transient failures)
- Exec dashboard tabs: show error state instead of fake zeroes
- Cost baselines: toast on save failure
- Audit log export: toast on failure
- Admin settings: toast when toggle state fails to load
- Leaderboard: error state when queries fail
- Registry home: surface error text on session load failure
- API client: sanitize raw error messages (tracebacks, long text)
- Insights HTML export: retry with fresh token on 401
- useDeploymentConfig: expose configError for consumers
@VishnuM049 VishnuM049 force-pushed the fix/frontend-error-handling branch from 11ebec8 to b5feba6 Compare June 22, 2026 23:24
@VishnuM049 VishnuM049 marked this pull request as ready for review June 22, 2026 23:37
@Haz3-jolt Haz3-jolt merged commit 8b8e8b1 into BlazeUp-AI:main Jun 23, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

web Pull request touches web frontend code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants