Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout + abort to Link prefetching to prevent unclickable Links #25330

Closed
karlhorky opened this issue Jun 26, 2020 · 3 comments
Closed

Add timeout + abort to Link prefetching to prevent unclickable Links #25330

karlhorky opened this issue Jun 26, 2020 · 3 comments
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@karlhorky
Copy link
Contributor

karlhorky commented Jun 26, 2020

Description

If the background prefetch request triggered by hovering <Link /> elements does not complete, subsequent clicks on the link appear to be broken.

Eg. Hovering over a link on a page that has not yet been prefetched (or is stale) leads to a prefetch requests to /page-data/app-data.json (due to the call to loader.loadPage() in cache-dir/navigation.js -> navigate()).

Kapture 2020-06-26 at 16 27 11

Steps to reproduce

  1. Simulate a never-returning (pending) response to requests to /page-data/app-data.json. This can be done with eg. an Express server route in front of Gatsby that never returns a response.
  2. Links no longer work, without any feedback to the user

Expected result

The links should go to the href location when they are clicked on.

Suggested solution

  1. When the user clicks on a link
    1. no event.preventDefault() call - navigation to the href should work
    2. maybe: any prefetches should be hard aborted
  2. Add timeout to prefetching functions

I would also suggest considering a general timeout for all other prefetches. Maybe built into a fetch wrapper.

Actual result

The links appear to be broken when clicked on (more keywords: non functional, not working)

Environment


  System:
    OS: macOS 10.15.5
    CPU: (4) x64 Intel(R) Core(TM) i7-6567U CPU @ 3.30GHz
    Shell: 5.5.1 - /usr/local/bin/zsh
  Binaries:
    Node: 13.12.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.5 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 83.0.4103.116
    Firefox: 77.0
    Safari: 13.1.1

Related issue

Links not working after period of inactivity: #4779

My comment on the issue: #4779 (comment)

@karlhorky karlhorky added the type: bug An issue or pull request relating to a bug in Gatsby label Jun 26, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 26, 2020
@karlhorky karlhorky changed the title Add timeout + abort to Link prefetching (and other prefetching?) to prevent unclickable Links Add timeout + abort to Link prefetching to prevent unclickable Links Jun 26, 2020
@blainekasten blainekasten removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 29, 2020
@karlhorky
Copy link
Contributor Author

Not sure if this is related enough to this issue, but:

Maybe the request code could also have a try ... catch around it (in addition to the timeout), to prevent issues where failed pre-loading of assets causes JavaScript on the page to fail:

#20745 (comment)

@LekoArts
Copy link
Contributor

Hi!

I'm closing this as a stale issue as in the meantime Gatsby 4 and related packages were released. You can check our Framework Version Support Page to see which versions currently receive active support. If this is a feature request, please create a discussion as we moved feature requests from issues to GitHub Discussions.

Please try the mentioned issue on the latest version (using the next tag) and if you still see this problem, open a new bug report. It must include a minimal reproduction.

Thanks!

@karlhorky
Copy link
Contributor Author

I haven't seen this for a while, so probably fine that it's closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants