Skip to content

Conversation

@Zaimwa9
Copy link
Contributor

@Zaimwa9 Zaimwa9 commented Oct 30, 2025

Closes #347
Problem
When initial fetching of flags failed using one of the lib react hook (500, 403), the promise rejection is unhandled, causing console errors and surfacing the error to the parent app.

Changes

  • Added .catch in react.tsx when calling init to prevent unhandled rejections
  • emit an event to update react hooks
  • Ensure flags default or disabled if not provided
  • Error captured in loadingState.error

Test

  • Added a test covering the case

Before fix:
image

After fix:
image

@Zaimwa9 Zaimwa9 requested a review from a team as a code owner October 30, 2025 10:04
@Zaimwa9 Zaimwa9 requested review from talissoncosta and removed request for a team October 30, 2025 10:04
Copy link
Contributor

@talissoncosta talissoncosta left a comment

Choose a reason for hiding this comment

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

Looks good overall. Let's just check the ; usage.

@Zaimwa9
Copy link
Contributor Author

Zaimwa9 commented Nov 11, 2025

@talissoncosta, removed trailing comma and semi-colon from linter configuration. The diff is only coming from the linter in the new commit.
I believe the rules were set but the formatting hadn't been applied before. Let me know if you prefer different rules, i'm not strongly opiniated

@talissoncosta
Copy link
Contributor

@Zaimwa9 thanks for handling that. It looks pretty good to me.
Yep, I see what you mean, It is all good to me, as long as we apply the same rules we don't add extra changes to the PRs.

@Zaimwa9 Zaimwa9 merged commit 5380dc3 into main Nov 11, 2025
1 check passed
@Zaimwa9 Zaimwa9 deleted the fix/catch-init-error-in-use-flagsmith branch November 11, 2025 12:17
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.

[React] FlagsmithProvider throws error when flagsmith.init fails by some reason to fetch flags

3 participants