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

Page refreshed after timeout instead of redirected #475

Closed
Tracked by #703
Mamboleoo opened this issue Nov 28, 2019 · 26 comments · Fixed by #653
Closed
Tracked by #703

Page refreshed after timeout instead of redirected #475

Mamboleoo opened this issue Nov 28, 2019 · 26 comments · Fixed by #653
Assignees
Milestone

Comments

@Mamboleoo
Copy link

Mamboleoo commented Nov 28, 2019

The problem

When the server takes too long to answer from a fetch, the page gets refreshed instead of redirecting the user to the target page.
It seems to be a regression since V2.8.0.
I tested with versions 2.6.1 and 2.7.2 and both are working correctly.
It's easy to reproduce by setting a very low timeout option value.

Description

See this screenshot using the version 2.8.0 where the problem occurs
image

See this screenshot using the version 2.6.1 without the problem
image

Steps to reproduce issue [ Good To Have ]

Broken demo

  1. Go to: https://mamboleoo.be/barba/
  2. Open devtools and simulate 3G slow connection
  3. Click on test url
  4. You stay on the same page instead

Working demo

  1. Go to: https://mamboleoo.be/barba/old.html
  2. Open devtools and simulate 3G slow connection
  3. Click on test url
  4. You are redirected to the target page

Environment

  • Barba version that exhibits the issue: ^2.8.0
  • Browser OS/version used: All

Thanks for having a look at this!

@xavierfoucrier
Copy link
Member

Hi @Mamboleoo,

Have you try to disable the default barba prefetch behavior?
Just to see if its related.

Thanks 😉

@Mamboleoo
Copy link
Author

I updated the demo and the issue is still occurring even with prefetchIgnore: true :/
https://mamboleoo.be/barba/

@xavierfoucrier
Copy link
Member

Good catch, its a bug, thanks for pointing this out! 😃

@thierrymichel
Copy link
Member

@Mamboleoo,

Could you try with:

barba.init({
    debug: true,
    timeout: 100,
  });

Really weird but I can reproduce your issue only with no debug.
With debug: true, it redirects as expected… 🙃🤔

@thierrymichel
Copy link
Member

@Mamboleoo,

Nervermind, got it… :)

@thierrymichel
Copy link
Member

thierrymichel commented Dec 9, 2019

Hi @Mamboleoo could you check if it's ok with 2.9.5?
Thanks in advance

@gamehelp16
Copy link

Looks like the problem still exists on 2.9.6, and like in @thierrymichel's case the issue doesn't occur when debug is set to true.

Not sure if this is intentional or not, but I also found that the page also gets refreshed instead of being redirected when clicking on a link to a page on the same site, but that page doesn't have barba wrapper nor container (let's say that I intentionally designed that page to not use barba). However, in this particular case the issue persists even with debug: true unlike in the timeout issue above.

@Mamboleoo
Copy link
Author

Mamboleoo commented Jan 22, 2020

@thierrymichel Sorry I just got back on the project where I'm using Barba.
I'm testing version 2.9.7 and the bug seems to be still there.
When using debug:true it doesn't refresh the page (so the expected behaviour) and I'm getting those console errors.
image

@nicolas-cusan
Copy link
Contributor

@Mamboleoo I am having the same issue. Did you manage to find a fix? Can you reopen this issue?

@xavierfoucrier
Copy link
Member

Hi @nicolas-cusan @Mamboleoo,

I just tested and it looks like this issue is patched, the reproductible repo of @Mamboleoo work as expected: the page redirect to the appropriate URL and doesn't refresh the current one.

Thanks for your feedbacks 😉

@nicolas-cusan
Copy link
Contributor

@xavierfoucrier thank you for the heads up! Will there be a new npm release that includes the patch soon?

@xavierfoucrier
Copy link
Member

Hi @nicolas-cusan,

This have been patched months ago by @thierrymichel in 281c85f.

But as you leave a comment, I want to be sure of that.
Can you share a reproductible repo where you are facing this issue?

Be sure to use the latest @barba/core@2.9.7

Thanks

@nicolas-cusan
Copy link
Contributor

nicolas-cusan commented Apr 27, 2020

@xavierfoucrier I do not have a reproductible repo that isolates that problem at the moment. I have the issue happening repeatedly on this website in production https://www.bold.ch/ (particularly on mobile). It uses @barba/core@2.9.7. The barba timeout is quite high at the moment so it does not happen often.

I will try to create a repo soon and share it here.

@xavierfoucrier
Copy link
Member

Thanks, waiting for your feedback with the minimal repo. 😉

@nicolas-cusan
Copy link
Contributor

Hi @xavierfoucrier, long time.

I finally have a site where this is reproducible in a reliable way (still in development):

Steps to reproduce:

  1. Go here: http://terra-vecchia.ch.antiqua.sui-inter.net/
  2. Use the main menu to transition to the team page using barba (right column 4th item, see screenshot)
  3. The page you are coming from will be reloaded

Background: The team page renders about a 100 records from the backend, the server response time is therefor really long (will be cached for production), but still this does represent the issue pretty well.

Thank you for taking a look!

Barba Version: 2.9.7

Screen Shot 2021-05-04 at 12 35 16

@xavierfoucrier
Copy link
Member

Hi @nicolas-cusan!

Yeah, about a year ago haha 😄

Well, I understand your problematic, the fact is that if you don't want to touch anything and fix this, you will need to increase the timeout: there is nothing else that can tell Barba to wait for your page to load and not reload the whole page.

BUT.. the fact is that you could use something pretty different, like this workflow:

  • the user click on the "Team" link
  • the "Team" page loads without all your content stuff
  • you display an animation or something telling the user that the content will take some time to load
  • you preload your content using an async request inside the "Team" page

This way, Barba will not "timeout" your page, and there won't be any reload 😎

@nicolas-cusan
Copy link
Contributor

Hello @xavierfoucrier,

thank you so much for your fast reply! And thank you for your tips.

The issue is not so much the reload/lack of transition (some users do not even notice), but that the user ends up on the same page he was before. In older versions (1.x) a timeout would cause a full page load but the the user would end up at the target page (team in this case). The current behavior is kind of bad from a UX / progressive enhancement point of view as the user clicks a link and does not end up there (not even with a reload).

Is there a recommended way to force the link to go through if the request times out, even if it is without a transition?

@nicolas-cusan
Copy link
Contributor

nicolas-cusan commented May 4, 2021

For anybody having this issue, I ended up setting debug to true in production ¯_(ツ)_/¯.

I tried to use requestError to properly handle the behaviour with no luck. It seems that this part of the code always gets triggered no matter what when a timeout occurs and debugging is switched off. (Haven't had time to properly test it though).

@xavierfoucrier
Copy link
Member

Hey @nicolas-cusan,

Yes I probably would have asked you to test request error...
Looks like we need to dive into this a little bit more and improve the default behavior.

I am reopening the issue and will discuss that with Thierry next time 😉
Thanks again for your feedback. 👌

@xavierfoucrier xavierfoucrier reopened this May 4, 2021
@nicolas-cusan
Copy link
Contributor

Thank you for looking further into it! 🙌

@ugrupp
Copy link

ugrupp commented Sep 3, 2021

Hey, any news on this? I can confirm @nicolas-cusan `s points and observations.

On timeout, I'd definitely expect a redirect to the target page, instead of reloading the current page. Wouldn't this just be a matter of replacing this with something like this.data.next.url? Could we perhaps make it configurable?

@stefanvangastel
Copy link

stefanvangastel commented Nov 10, 2021

Having the same issue on a Wordpress theme equipped with BarbaJS. Running on localhost (fast DB) everything works fine, when using a remote DB (somewhat slower) this behaviour is shown.

@grappler
Copy link

grappler commented Jan 7, 2022

Can also confirm that I have the same issue. Have implemented the fix in #653 and it seems to work.

@thierrymichel thierrymichel added this to the barba@next milestone Jan 31, 2022
@faroutchris
Copy link

faroutchris commented Jul 2, 2022

I seem to experience a related issue. Page refreshes if the request is pending (but not on timeout)

I have a page with a very basic barbajs implementation here: https://www.reddigital.dev/

Steps to reproduce:

  • Go to the network tab in your browser devtools and set the connection speed to Slow 3G
  • When you hover over the "BLOG" menu link, barbajs initiates a request to /about
  • While the request is still pending, clicking on the link only causes the current page to reload.
  • If you wait for the timeout, ie for the request to be cancelled, the link behaves correctly.

So just to be super clear:

Clicking when the page is in this state will reload the current page

pending

Clicking after the timeout behaves as expected

canceled

This happens on every hover + click. So for this site to work on a slow connection, the user has to hover over the link for 2 seconds before clicking on it.

@stepanjakl

This comment was marked as outdated.

@xavierfoucrier xavierfoucrier self-assigned this Nov 25, 2022
@xavierfoucrier
Copy link
Member

Closed by #653.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants