There have been two instances reported where the service worker responds to a fetch with a null response, which is illegal. It does this because it assumes that the static assets are always in the cache. Clearly that assumption doesn't always hold, and it's easy to fix by just awaiting the result of cache.match and only responding with it if there is a non-null value.
This necessitated moving a bit of code around and I took the opportunity to refactor the code a little bit.
Fixes sveltejs/sapper#1432 (even though I don't know the exact circumstances that lead to the assets not being in the cache) and fixes sveltejs/sapper#1587.
There have been two instances reported where the service worker responds to a fetch with a
null
response, which is illegal. It does this because it assumes that the static assets are always in the cache. Clearly that assumption doesn't always hold, and it's easy to fix by just awaiting the result ofcache.match
and only responding with it if there is a non-null value.This necessitated moving a bit of code around and I took the opportunity to refactor the code a little bit.
Fixes sveltejs/sapper#1432 (even though I don't know the exact circumstances that lead to the assets not being in the cache) and fixes sveltejs/sapper#1587.