Skip to content

fix(settings): handle preferences fetch failure instead of hanging#71

Open
Chzhqv wants to merge 1 commit into
TemaDeveloper:mainfrom
Chzhqv:fix/settings-preferences-fetch-error-handling
Open

fix(settings): handle preferences fetch failure instead of hanging#71
Chzhqv wants to merge 1 commit into
TemaDeveloper:mainfrom
Chzhqv:fix/settings-preferences-fetch-error-handling

Conversation

@Chzhqv

@Chzhqv Chzhqv commented Jul 7, 2026

Copy link
Copy Markdown

Summary

  • useEffect fetching /api/user/preferences only chained .then(), with setLoading(false) called inside it. A rejected fetch (network drop, or a 5xx whose body throws in .json()) left loading stuck at true forever, so the page never left the Skeleton.
  • Added .catch to surface an error toast and .finally to always clear loading.

Test plan

  • Added a regression test (settings/__tests__/page.test.tsx) mocking a rejected preferences fetch — confirmed it fails without the fix (unhandled rejection) and passes with it
  • pnpm lint, tsc --noEmit, full vitest run (557/557) all pass

Fixes #20

The /api/user/preferences fetch in useEffect only chained .then(),
with setLoading(false) called inside it. A rejected fetch (network
drop, or a 5xx whose body throws in .json()) left loading stuck at
true forever, so the page never left the Skeleton. Add .catch to
surface an error toast and .finally to always clear loading.

Added a regression test (confirmed it fails without the fix, passes
with it) since this bug is easy to silently reintroduce.

Fixes TemaDeveloper#20
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Artemii's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Settings preferences fetch has no catch/finally → stuck loading skeleton

1 participant