CDPedia icon indicating copy to clipboard operation
CDPedia copied to clipboard

Watchdog timer broken when using browser's back button

Open fzuccolo opened this issue 4 years ago • 0 comments

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:

https://github.com/PyAr/CDPedia/blob/61f73b4295151aa55b17e3577f31664f129403bd/src/web/templates/cdpedia_base.html#L27-L31

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

https://github.com/PyAr/CDPedia/blob/61f73b4295151aa55b17e3577f31664f129403bd/src/web/web_app.py#L254-L261

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 avatar Apr 03 '21 17:04 fzuccolo