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

Prefetch links that 404 should fall back to the network #3977

Closed
swyxio opened this issue Feb 17, 2022 · 3 comments
Closed

Prefetch links that 404 should fall back to the network #3977

swyxio opened this issue Feb 17, 2022 · 3 comments

Comments

@swyxio
Copy link
Contributor

swyxio commented Feb 17, 2022

Describe the bug

i had a bug reported here: https://twitter.com/clearhunch/status/1494317555275677696?s=21

that essentially came from me using a prefetch link (<a svelte:prefetch href=“/LIP”>) for a url that only exists as a serverside redirect (in netlify). in a normal a href context that would work. but sveltekit is being too smart, or not smart enough, here. it checks its cache for a page called “LIP”, and not finding it, returns a 404 and end of story. i think it should deopt from clientside navigation and go actually check the network, and let the 404 handling happen there (again via sveltekit).

see what i mean? basically the only reason we do clientside nav is to make it fast, but we dont have to be fast for 404’s.

Reproduction

the diff i made swyxio/swyxdotio@4f16ef6

its really obvious but it is an abstraction leak, and yes i know i could just remove prefetch but why make me check

Logs

No response

System Info

n/a

Severity

annoyance

Additional Information

No response

@geoffrich
Copy link
Member

This sounds related to #3935, though that issue doesn't call out prefetch specifically.

@Rich-Harris
Copy link
Member

Just merged and released #3969 — does that solve this issue @sw-yx?

Aside: if you implemented the server-side redirect as a load function instead you could avoid the roundtrip:

<!-- src/routes/LIP.svelte -->
<script>
  export function load() {
    return {
      status: 308,
      redirect: '/learn-in-public
    };
  }
</script>

@swyxio
Copy link
Contributor Author

swyxio commented Feb 23, 2022

i think it does, will close for now as something else broke in swyxkit when i updated deps so i am debugging multiple things at once

thank you

@swyxio swyxio closed this as completed Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants