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.

Prefetch broken — `Cannot read property 'load' of undefined`

See original GitHub issue

Describe the bug Trying to prefetch a route programatically errors when trying to call load on the prefetched route

Logs

Screen Shot 2021-05-31 at 10 59 26 AM

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
benmccanncommented, Aug 6, 2021

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?

1reaction
xpycommented, Jul 6, 2021

manual prefetch happens before the Router is initialized and thus the this.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

Read more comments on GitHub >

github_iconTop 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 >

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