-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Trouble catching fetch
errors in module context load
#4659
Comments
Isn't this expected behavior? |
Surely an infinitely looping |
5 tasks
Rich-Harris
added a commit
that referenced
this issue
Jul 8, 2022
Rich-Harris
added a commit
that referenced
this issue
Jul 11, 2022
Rich-Harris
added a commit
that referenced
this issue
Jul 14, 2022
Rich-Harris
added a commit
that referenced
this issue
Jul 14, 2022
* failing test for #4659 * prevent infinite loop when loading non-existent route in __layout * update test * tighten up * changeset * Update .changeset/purple-rats-wink.md * wut
closed via #4665 — thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Adding module context
load
functions withfetch
attempts to non-existent resources seems to introduce errors that can't be caught. Similarfetch
calls in the non-module context script tags can have their errors caught in the expected way:Additionally,
fetch
errors in__layout.svelte
specifically will cause an infinite loop as theload
function is run over and over again.Reproduction
In the template SvelteKit to-do application, add something to the effect of:
If this is in
__layout.svelte
, the "Attempting to fetch..." line will be printed indefinitely as the load hangs. If this is in a specific route (like the About page), navigation will not hang but the error will also not get caught.If this
fetch
is not in module context, the error is caught and the "Caught an error!" line is printed. If thefetch
is changed to an existing resource ("-favicon" -> "favicon", for example), everything works fine as well.Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
I can work around this issue by moving the
fetch
calls into the main script to correctly catch any errors, but this is obviously non-ideal as content will flash/jump as it's loaded in.Really hoping this is me missing something obvious, and apologies if that's the case! I tried asking about this in the Svelte Discord a couple times but got no response.
The text was updated successfully, but these errors were encountered: