riverpod icon indicating copy to clipboard operation
riverpod copied to clipboard

Make sure uncaught exceptions within providers are properly reported to the zone

Open rrousselGit opened this issue 2 years ago • 3 comments

Currently if an exception is thrown within a Provider/FutureProvider/... then the exception is never sent to the zone.

This is "alright" for a Provider, as they rethrow the error on read. But a FutureProvider does not and instead return the value as AsyncError, which can be ignored

Let's make sure that if a provider throws, the Zone knows it.

rrousselGit avatar Apr 27 '22 10:04 rrousselGit

looks like issues are related https://github.com/rrousselGit/riverpod/issues/1377 uncaught exception occurs and this causes the item FutureProvider.family state to get stuck in AsyncLoading state

nailgilaziev avatar Apr 28 '22 10:04 nailgilaziev

I'm having an issue with my program early exiting, and from this thread I suspect it may be due to this uncaught exception error. Can you advise a recommended work around for this particular issue, so that I can see if its the cause of what I'm experiencing?

FWIW, I believe this is actually the second project in which I've had this issue, but the root cause is almost impossible to debug and track down that its easy to spend hours scratching your head and never realize its from riverpod. In other words, its likely that more devs experience this issue than have reported it, and the lack of visibility into error reporting makes this a high impact issue IMO.

pattobrien avatar Feb 19 '23 16:02 pattobrien

Considering #1580, It seems that uncaught exception in build() is ignored very silently for now. At least one of the issues should be solved.

jeiea avatar May 16 '23 03:05 jeiea