-
Notifications
You must be signed in to change notification settings - Fork 340
resource-display.php refreshes after 60 seconds and breaks the page #1201
Description
When opening the public resource display page, it loads correctly at first, but after ~60 seconds the page breaks. This appears to be caused by the automatic refresh, not the initial load.
I am using LibreBooking version 4.2, and the same issue was also present in version 4.1. I have cleared the tpl_c directory to rule out cached templates, but the problem persists.
In ResourceDisplay.prototype.initDisplay, the page is refreshed every 60 seconds:
refreshResource();
setInterval(refreshResource, 60000);
The issue occurs when the timed refreshResource() runs. The initial render works, but the AJAX refresh after 60 seconds causes the display to fail.
Inside refreshResource() the response is directly injected into the DOM:
ajaxGet(url, null, function (data) {
elements.placeholder.html(data);
});
If the backend returns unexpected content (e.g. login page, error page, redirect response, or empty/invalid HTML), it replaces the display and breaks the page.
There is also no protection against overlapping refresh calls or failed AJAX requests.
Observed behavior:
Page loads correctly
After ~60 seconds (first refresh), the page breaks
Expected behavior:
The resource display should continue refreshing without breaking, even if a refresh request fails or returns unexpected data.