Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silent error in getKey within useSWRInfinite #2102

Open
onlyanegg opened this issue Aug 3, 2022 · 2 comments
Open

Silent error in getKey within useSWRInfinite #2102

onlyanegg opened this issue Aug 3, 2022 · 2 comments

Comments

@onlyanegg
Copy link

Bug report

Description / Observed Behavior

useSWRInfinite hides errors within getKey (at least on the first page load). The error in getKey seems to cause the fetcher not to run. Because the error is hidden, it's difficult to debug.

Expected Behavior

I expect it to raise or display the error

Repro Steps / Code Example

import useSWRInfinite from "swr/infinite";

useSWRInfinite(                    
  () => {                          
    throw new Error();             
  },                               
  () => fetch("http://example.com")
);                                 

Additional Context

swr@1.3.0

onlyanegg added a commit to onlyanegg/swr that referenced this issue Aug 3, 2022
@quantran020173
Copy link

This I a feature name "Conditional Fetching", not a bug https://swr.vercel.app/docs/conditional-fetching. And why do you want to throw an error in getKey?

@onlyanegg
Copy link
Author

This isn't about conditional fetching; it's about hiding an error. I don't want to raise an error in the getKey function; this was a minimal example for reproduction. When there is an error in the getKey function, it's hidden which makes it difficult to debug. I'd like to either raise that error or log it.

@koba04 koba04 added the area: pagination Pagination related issues label Nov 30, 2022
@koba04 koba04 added area: infinite and removed area: pagination Pagination related issues labels Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants