One failed preload can break a route for Safari users
Summary
Safari reused a failed `modulepreload` instead of fetching the file again, so a single failed route chunk could leave that route dead for the rest of the page's life.
Make a route chunk's first request fail in a test and confirm the later import sends a second network request, because the fix has only reached Safari's preview build.
A failed modulepreload request in WebKit could stay in the memory cache marked as preloaded, and a later import() of the same URL would then reuse that failed entry and reject without making another network request. Safari Technology Preview 255 moves the error check ahead of the cache shortcut, a change Harry Roberts, an independent web performance consultant, wrote up in his Web-Perf Wednesday series this month. The fix is in the preview build only.
modulepreload tells the browser to fetch a JavaScript module early so it is ready when the application asks for it. The common use is the route chunk: preload the module for the page the user is probably about to open, then import() it when they click. One failed fetch of that chunk, a blip at the CDN or an interrupted request, used to leave the module unavailable for the rest of the page’s life. The retry never happened, because as far as the memory cache was concerned the resource had already been dealt with.
What the user gets is a link that does nothing. The click produces a rejected promise, and an app that does not handle it shows nothing. For a route whose content only appears after that import, the chunk is the page. Routes built that way are already invisible to ChatGPT, Claude and Perplexity, which do not render JavaScript, and this bug hid them from Safari users as well.
Roberts’s post recommends watching import() rejections and network requests as separate signals, and that is the part worth doing before the fix ships. The post does not spell this out, but the two failures look identical in most error tracking: a rejection with no second request in the waterfall is this cache bug, while a rejection after a second request that also fails is a chunk that is genuinely missing. One is fixed by retry logic, the other by a deploy.
The tempting workaround is a cache-busting query string on the retry, and Roberts’s post argues against it. A random query string creates a different module-map entry, so it can appear to fix the symptom while changing the request the application was supposed to recover. The better move is to retry the original URL, with a delay and a bounded number of attempts.
What to do
- Make a route chunk’s first request fail in a test, restore the file, and confirm the later
import()sends a second network request. Roberts’s post recommends putting that test in the deploy pipeline if your bundler emits module preloads for split chunks. - Run the same test at the CDN and service-worker layers, either of which can keep serving the failure on its own.
- Keep the retry and recovery code you already have. The Safari Technology Preview 255 release notes do not say the fix has reached stable Safari, so it is something to verify per release rather than permission to delete the fallback.
- Give the user a visible way to try again, since the default outcome of a rejected import is a dead link and no explanation.