fix: surface observable errors via status instead of re-throwing#735
Open
tyler-reitz wants to merge 4 commits into
Open
fix: surface observable errors via status instead of re-throwing#735tyler-reitz wants to merge 4 commits into
tyler-reitz wants to merge 4 commits into
Conversation
Removes the unconditional re-throw in useObservable that made status: 'error' unreachable. Errors are now returned in ObservableStatus so consumers can handle them locally via status checks. Users who want Error Boundary behavior can opt in by throwing the error themselves. Fixes FirebaseExtended#535, fixes FirebaseExtended#540
Contributor
There was a problem hiding this comment.
Code Review
This pull request bumps the package version to 4.3.0 and modifies useObservable to surface errors via the status field instead of throwing them. Feedback highlights that completely removing the error throw breaks the React Suspense contract, where errors should be caught by an ErrorBoundary. It is recommended to conditionally throw errors when suspense is enabled and to update the tests accordingly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Preserves Error Boundary behavior for suspense mode while allowing non-suspense consumers to handle errors locally via status === 'error'.
f6fc807 to
6c015ca
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
useObservableunconditionally re-throws errors from the underlying observable, makingstatus: 'error'unreachable in practice. Users in non-suspense mode who want to handle errors locally have no way to do so:The original code included a TODO from the author questioning whether this behavior was correct.
Fix
Error handling now matches the mode the consumer opted into:
suspense: true): errors still throw, so React Error Boundaries catch them as expected. This preserves the idiomatic Suspense contract.suspense: false): errors are returned viastatus: 'error'so consumers can handle them locally.Breaking change
This affects the default usage pattern. Non-suspense mode is the default — if you don't pass
suspense: trueor wrap your app in aSuspenseEnabledContext, you are in non-suspense mode.Before 4.3.0, errors from any reactfire hook would throw unconditionally, regardless of mode. After 4.3.0:
status, no change needed.Fixes #535, fixes #540