Prefetch broken — `Cannot read property 'load' of undefined`
See original GitHub issueDescribe the bug
Trying to prefetch
a route programatically errors when trying to call load
on the prefetched route
Logs
To Reproduce
Call prefetch
on a route if browser
is true
if (browser) {
prefetch('/some-route')
}
Expected behavior Prefetch should work…
Information about your SvelteKit Installation:
Diagnostics
System:
OS: macOS 11.2.1
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 684.30 MB / 16.00 GB
Shell: 5.7.1 - /usr/local/bin/zsh
Binaries:
Node: 14.17.0 - /usr/local/bin/node
Yarn: 1.22.4 - ~/.yarn/bin/yarn
npm: 6.14.13 - /usr/local/bin/npm
Browsers:
Chrome: 91.0.4472.77
Firefox: 74.0
Safari: 14.0.3
-
Your browser: Chrome
-
Your adapter:
adapter-static
, though occurs in dev and preview as well
Severity Moderate — cannot use programatic prefetching to improve performance.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Why am I getting ,, Cannot read property 'load' of undefined
I have defined cookie in my project like this. import cookie from 'react-cookie'. So that means I have defined cookie so I shouldn't...
Read more >How to Read React Errors (fix 'Cannot read property of ...
This error usually means you're trying to use .map on an array, but that array isn't defined yet. That's often because the array...
Read more >Route prefetching in Next.js - web.dev
Click the Network tab. Select the Disable cache checkbox. Reload the page. When you load index.js , the Network ...
Read more >Server-Side Rendering (SSR) - Vue.js
Server-rendered markup doesn't need to wait until all JavaScript has been downloaded and executed to be displayed, so your user will see a...
Read more >Google Chrome Privacy Whitepaper
To improve load times, the browser can be asked to prefetch links ... If Google is set as your default search engine, Chrome...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this might be fixed now. I just tried https://github.com/madeleineostoja/portfolio/tree/prefetch-bug with the latest version of SvelteKit and don’t see the error originally reported. Can you check if you’re still seeing this?
manual
prefetch
happens before the Router is initialized and thus thethis.renderer
is undefined. Init of renderer happens here: https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/client/router.js#L34 prefetch tries to access the renderer here: https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/client/router.js#L217