Skip to content

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

Merged
TemaDeveloper merged 1 commit into
TemaDeveloper:mainfrom
Chzhqv:fix/settings-preferences-fetch-error-handling
Jul 7, 2026
Merged

fix(settings): handle preferences fetch failure instead of hanging#71
TemaDeveloper merged 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.

@TemaDeveloper TemaDeveloper left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@TemaDeveloper
TemaDeveloper merged commit d2a6a41 into TemaDeveloper:main Jul 7, 2026
3 of 4 checks passed
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

2 participants