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.

Describe the problem

SvelteKit include the ability to prefetch pages while the user is hovering over a link. However, a the prefetched data might not be relevant after a period of time, so when the user will click on the link, say after a minute, she will get old data.

Describe the proposed solution

I think the simple solution is to allow to specify timeout. Either allow to specify timeout in a syntax similar to <a sveltekit:prefetch={timeout: (time in seconds)} ...>, or get the timeout from an optional “timeout” property in the return value of load() function, or even support both solutions.

A better/additional aprouch to the simple “timeout” property in my opinion, is to allow the developer to give a predicate: function dataValidity(lastPrefetchedTime): boolean

Alternatives considered

The manual alternative would be to use some custom svelte action in the <a> tag which calls prefetch() manually and call it again if the user hover/click on the link after a certain amount of time.

Sadly, as far as I know, there is not even a way to invalidate the prefetched data manually. (the invalidate() works only for the currently active page acoording to the docs)

Importance

would make my life easier

Additional Information

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dummdidummcommented, Sep 21, 2022

@Christian-E once #6924 is released invalidate will also invalidate prefetched data.

1reaction
Rich-Harriscommented, Apr 25, 2022

We recently made a change such that instead of returning maxage from load, you return a cache object. One idea that occurs to me is adding a prefetchTimeout property (name subject to bikeshedding, obviously) that, if maxage isn’t specified, defaults to the global config.kit.prefetchTimeout (which defaults to some number of milliseconds — say 5000 for the sake of argument).

I think that makes more sense than putting it in the attribute, since there’s no reason you’d ever have different values for two links that pointed to the same page.

<script context="module">
  export const load = ({ props }) => ({
    props,
    cache: {
      // for this page, treat data as stale if users hovers on link for >1s
      prefetchTimeout: 1000
    }
  });
</script>
Read more comments on GitHub >

github_iconTop Results From Across the Web

prefetch v3.0.0 : timeout exhausted while creating file ... - GitHub
Hello there, I'm using prefetch v3.0.0 - lots of my jobs fail with error messages like this : 2022-03-21T19:03:30 prefetch.3.0.0 int: ...
Read more >
Adapter Prefetch Times Out - SAP Help Portal
Adapter Prefetch Times Out. When task execution fails due to an adapter timeout, you may need to adjust the adapter prefetch timeout parameter....
Read more >
Timeout exhausted using prefetch - Biostar
I use prefetch to get some files, it turns out the following: prefetch.2.8.0 sys: timeout exhausted while reading file within network system module ......
Read more >
SAP HANA - Prefetch timed out error
When You run a replication task or an activity of large tables in HANA Smart Data Integration sometimes You receive below error:
Read more >
[403] internal error: Remote execution error Prefetch timed out
[403] internal error: Remote execution error Prefetch timed out. Ad. Hello Everyone,. While running a Rep task or an activity of large tables...
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