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

Bug: Prismic toolbar new tab refresh loop. #66

Closed
danielhuggins opened this issue Jul 16, 2020 · 6 comments · May be fixed by #82
Closed

Bug: Prismic toolbar new tab refresh loop. #66

danielhuggins opened this issue Jul 16, 2020 · 6 comments · May be fixed by #82

Comments

@danielhuggins
Copy link

danielhuggins commented Jul 16, 2020

In certain situations, the prismic toolbar goes into a refresh loop.

Steps to reproduce.

  1. Start a new preview session in a certain page.
  2. Open another page in a new tab. For some reason this only works on pages that are slower to load, or maybe that have a lot of javascript in them.
  3. Close the preview session from the new tab.
  4. The new tab page goes into a refresh loop, refreshing over and over and over again.

This actually managed to take our server down from getting hammered by the refresh loop. (It was on a heavy data export page). Please fix it, as we are using a messy workaround in the meantime.

@paulnta
Copy link

paulnta commented Apr 6, 2021

I have the same problem where my page gets stuck in a refresh loop right after hitting "Save" in Prismic. It happens when the page takes more than 3 seconds to load. (eg. Long time to first byte)

Cause:
I think it's related to the following function updatePreview() which is called every 3 seconds:

async updatePreview() {
const { reload, ref } = await this.client.updatePreview();
this.start(ref);
if (reload) { reloadOrigin(); }
}

What happens is

  1. reloadOrigin() is called for the first time (after changes are made on Prismic)
  2. The page starts reloading...
  3. After 3 seconds, reloadOrigin is called again. But this will automatically cancel the previous reload.
  4. The page starts reloading again
  5. and so on...

Potential fix:
call reloadOrigin only if there is no other reload in progress.

I'm happy to submit a PR for this if you want.

@paulnta
Copy link

paulnta commented Apr 6, 2021

call reloadOrigin only if there is no other reload in progress.

Or simpler, just call this.cancelPreviewUpdates() before calling reloadOrigin()

@danielhuggins
Copy link
Author

danielhuggins commented Apr 6, 2021 via email

@paulnta
Copy link

paulnta commented Apr 6, 2021

@danielhuggins If you see some request to your page with the status (canceled) (eg. in Chrome DevTools > Network tab), then it means you may have the same bug

@angeloashmore
Copy link
Member

Hey @danielhuggins @paulnta, PR #97 should address the issue. It is pending a review.

@danielhuggins - The fix in your PR has been included in #97. Thanks for that fix! 👍

@angeloashmore
Copy link
Member

PR #97 has been merged and deployed. The latest version of the toolbar, v4.0.8, should not experience infinite refreshes as described in this issue.

If you experience infinite refreshing please reply here or open a new issue. Thanks! 🙂

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

Successfully merging a pull request may close this issue.

3 participants