question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should non-200 client-side navigations result in a page reload?

See original GitHub issue

If a page errors during SSR…

<script context="module">
  export function preload() {
    this.error(500, 'nope');
  }
</script>

…then the resulting error page is served with the appropriate status code. The same goes for 404s.

But if you navigate client-side from a page that renders ok (/good) to one that doesn’t (/bad), you don’t get an error status code because as far as the browser is concerned you’re not actually navigating.

Remix has an interesting take on this — they actually abort the client-side transition and reload /bad. Is this feature useful? It doesn’t seem particularly useful to me, but they seem quite excited about it so probably know something I don’t.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Conduitrycommented, Oct 29, 2020

This should possibly be a separate issue, but I do think that there should be a better way to deal with errors when rendering pages (whether on the server or on the client), so you can send them off to some logging service or whatever you want to do. Right now, Sapper is pretty greedy about swallowing errors, and it’s tricky to set something like this up.

A handler like this might also be a good place for someone to implement their own page reload, if that’s something they happened to want.

1reaction
benmccanncommented, Oct 29, 2020

Hmm, having the page reload seems like an unexpected behavior to me and it’s probably not what I’d want unless it provides some benefit I’m not thinking of. I’d be curious what the motivation for that feature in Remix is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-router URLs don't work when refreshing or writing ...
The historyApiFallback is what fixed this issue for me. Now routing works correctly and I can refresh the page or type in the...
Read more >
I don't get client side navigation. It's a worse experience in ...
Because it's faster. If you don't have to download all the content again, force the browser to re-render everything, then by design you...
Read more >
Handling SPA Fallback Paths in a Generic ASP.NET Core ...
This works just fine - as long as the user stays within the application and doesn't hard refresh the page. IOW, clicking through...
Read more >
Refreshing Server-Side Props - Next.js - Josh W Comeau
js to re-fetch the data, on demand, without doing a hard refresh of the whole page? In this short tutorial, I'll share the...
Read more >
Next JS Export to static HTML always redirect to home page ...
Test it on development mode yarn dev and visit the links and refresh each page. It will not redirect to / page. Build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found