Repository navigation
fix(teams): handle API errors and cleanup loading state in useTeam - #21289
FrancescoCastaldi wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This PR hasn't seen activity in two weeks! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the |
43608a9 to
6bc4959
Compare
A quick word from the signature departmentHey @FrancescoCastaldi, thanks for the PR! GitHub couldn't verify the signature on this commit:
PostHog requires verified commit signatures before merging. So we've built a bot to do the nagging. You're talking to it. Let's get this verifiedIf signing isn't set up yet, follow our signing guide or GitHub's guide. Already signed? Make sure GitHub recognizes your key. SSH keys must be registered as a Signing Key, not only as an Authentication Key. Once signing is set up, if the unsigned commit is your latest commit, run: git commit --amend --no-edit -S
git push --force-with-leaseThose commands fix only your latest commit. Older unsigned commits need signing too. Coordinate with anyone else using the branch before rewriting its history. Save your future self another visit from me: git config --local commit.gpgsign trueThat enables signing for future commits; it doesn't sign existing ones. A I'll check again after your next push and update this comment. |
Summary
Fixes #21280
When
/api/teamsfails or returns a non-200 response (such as a 500 error page or network block),useTeampreviously threw an unhandled rejection, causing team pages (/teams/<slug>) to stay indefinitely in their loading state becausesetLoading(false)was never reached.Changes
if (!res.ok) throw new Error(...)) infetchTeambefore callingres.json().fetchTeamwithsetTeam(undefined)to allow team pages and roster views to exit cleanly into their fallback state.useEffectto use.finally(() => setLoading(false))ensuring the loading state is always dismissed on both success and failure.Testing
loadingto false.