When Suspense is enabled, error thrown inside fetcher function is not thrown by SWR (swallowed)
Bug report
Description / Observed Behavior
Suspense is enabled when calling useSWR, and an error is thrown inside the fetcher function when attempting to fetch.
The error isn't being re-thrown by SWR, or reported as an uncaught error, and I am unable to handle it in an Error Boundary.
Expected Behavior
I would expect SWR to re-throw the error thrown in the fetcher function, and for me to be able to handle it with an Error Boundary, or for it to be reported as an uncaught error.
Instead, the error is not surfaced by SWR and is "swallowed".
Repro Steps / Code Example
https://codesandbox.io/s/silly-cookies-igxf7b?file=/pages/index.tsx
Additional Context
SWR version: 2.0.0-rc Nextjs version: 12.3.2-canary Suspense is enabled
That's because you're passing the fallbackData option. Remove that and it'll work.
That's because you're passing the fallbackData option. Remove that and it'll work.
oh hmm, does fallbackData also apply for client fetches, or just during server rendering? i'm triggering a fetch from the client in the example and still not seeing the error surface
(and in version 2.0.0-rc of SWR it seems that the fallbackData prop is required if the hook gets rendered in the server)
Same for me: