instant-multi-page-app icon indicating copy to clipboard operation
instant-multi-page-app copied to clipboard

/blog endpoint may just show "Loading postings..."

Open nolanlawson opened this issue 2 years ago • 2 comments

Hi, I love this demo you made. I think it's great how it illustrates that you can make a webapp with offline navigations that doesn't rely on a client-side router.

I noticed that for the /blog/ endpoint, it's possible for it to get stuck just showing "Loading postings...":

Screenshot from 2022-05-22 08-02-36

Steps to repro:

  1. Open a private/guest window
  2. Navigate directly to https://instantmultipageapp.com/blog/

This also works if you load the home page in a private/guest window, and then very quickly click on "blog."

I assume the service worker is looking for a cached response and not finding it, because the cache has not been populated yet?

I also noticed this bit of client-side code for loading the blog posts… Is this strictly necessary, if HTML is streamed from the service worker?

https://github.com/DannyMoerkerke/instant-multi-page-app/blob/c291425760b8a554a4721a554faf207654a4315e/blog/index.html#L45-L57

Again, great demo! Love the use of ReadableStreams as well. :slightly_smiling_face:

nolanlawson avatar May 22 '22 15:05 nolanlawson

Hi Nolan, thanks for reporting! Love your blog as well.

I'm looking into this now.

DannyMoerkerke avatar Jun 01 '22 07:06 DannyMoerkerke

Just fixed the issue.

The problem was that when /blog is directly visited and the Service Worker is not activated yet, it cannot load the cached response yet. The bit of client-side code you mentioned is actually meant to fetch the postings for exactly this situation, however, it wasn't loaded so the postings were not fetched.

DannyMoerkerke avatar Jun 01 '22 10:06 DannyMoerkerke