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

Watchdog timer broken when using browser's back button #384

Open
fzuccolo opened this issue Apr 3, 2021 · 0 comments
Open

Watchdog timer broken when using browser's back button #384

fzuccolo opened this issue Apr 3, 2021 · 0 comments
Labels

Comments

@fzuccolo
Copy link
Member

fzuccolo commented Apr 3, 2021

Issue reproduction

  1. start CDPedia
  2. navigate to an article
  3. return to the first page by pressing the browser's back button
  4. wait at least 2 minutes and try to navigate to another article
  5. the browser can't connect to CDPedia because the process ended

This is unexpected. The process should not be terminated while there's a CDPedia page opened in the browser.

Current behaviour

The current watchdog mechanism is implemented by embedding an iframe in each page:

{% if watchdog %}
<!-- Watchdog iframe -->
<iframe src="/watchdog/update" style="width:1px;height:1px;display:none;"></iframe>
<!-- /WatchDog iframe -->
{% endif %}

This iframe requests a dummy empty page that reloads itself every x seconds:

CDPedia/src/web/web_app.py

Lines 254 to 261 in 61f73b4

def on_watchdog_update(self, request):
self.watchdog.update()
seconds = str(int(config.BROWSER_WD_SECONDS * 0.85))
html = (
"<html><head><meta http-equiv='refresh' content='%s'></head><body></body></html>" % (
seconds,))
resp = Response(html, mimetype="text/html")
return resp

CDPedia will exit if more than BROWSER_WD_SECONDS seconds pass without hitting this endpoint.
This works great for all situation except the one described above.

Possible solutions

Adding {"Cache-Control": "no-cache, no-store, must-revalidate"} to the response headers of the watchdog endpoint fixes the issue in Chrome but not in Firefox. Maybe a solution with javascript should be explored.

@fzuccolo fzuccolo added the bug label Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant