Skip to content

fix: handle prompt detail fetch errors - #627

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
BharadwajKanneveti:fix/handle-prompt-detail-fetch-errors
Aug 4, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
BharadwajKanneveti:fix/handle-prompt-detail-fetch-errors

Conversation

@BharadwajKanneveti

Copy link
Copy Markdown
Contributor

Summary

Adds error handling to the prompt detail page to prevent it from getting stuck in a loading state when getPromptDetail fails.

Changes

  • Wrapped the prompt detail fetch in a try/catch/finally block.
  • Moved setLoading(false) into finally so the loading state is always cleared, even if the request fails.
  • Added toast.error to surface fetch failures to the user.
  • Preserved the existing cancellation guard to avoid state updates after the component unmounts.

This ensures transient fetch failures no longer leave the page displaying a permanent loading skeleton.

Related issue

Closes #591

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The try/catch/finally structure is right and the endless skeleton is fixed. One small change before merge: after a failed fetch, data stays null so the page falls into the existing notFound || !data branch and shows "Prompt not found — may have been deleted", which is misleading for a transient network error.

Suggestion: add a loadFailed state set in the catch, and render a distinct "Couldn't load this prompt" message (a Retry button re-invoking the load would be a nice touch) before the not-found branch — keeping "Prompt not found" for a successful fetch that returns nothing. #618 established this pattern on the Topics pages if you want a reference.

@BharadwajKanneveti

Copy link
Copy Markdown
Contributor Author

Hi @gkhngyk I have made the changes please check once.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Exactly what was asked — the distinct error card with retry before the not-found branch, and "Prompt not found" now reserved for a successful-but-empty fetch. Thanks!

@gkhngyk
gkhngyk merged commit c28c714 into ansvisor:main Aug 4, 2026
3 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.

Prompt detail page hangs on the loading skeleton forever when the data fetch fails

2 participants