[Pas2js] page reload when server restarted not 100% reliable
Luca Olivetti
luca at ventoso.org
Mon Sep 22 18:19:16 CEST 2025
El 22/9/25 a les 17:48, Luca Olivetti via Pas2js ha escrit:
> El 22/9/25 a les 17:11, Mattias Gaertner via Pas2js ha escrit:
>>
>>
>> On 9/22/25 16:19, Luca Olivetti via Pas2js wrote:
>>> I have ~20 clients (windows 11 in kiosk mode with edge as the kiosk
>>> application). They're touch screen only, no keyboard or mouse.
>>> The pas2j application tries to reload the page when the connection is
>>> severed (it's using a TJSEventSource and the server sends a message
>>> every 5 seconds).q
>>> The problem is that, from time to time, the page is blank (I cannot
>>> simply hit F12 to see what's happening since it's in kiosk mode).
>>> On a non-kiosk instance I found that the pas2js application or
>>> another js library wasn't completely loaded while starting the
>>> application hence causing an exception, so I came up with this
>>> workaround (and, yes, first I tried just with the try..catch but it
>>> didn't work).
>>
>> Wasnt completely loaded. Have you tried in the html:
>>
>> window.addEventListener("load", rtl.run);
>
> That's what the checkbox "Run RTL when all page resources are fully
> loaded" does.
>
> I'm not 100% sure but I think I tried. I'll try again though.
Now that I tried again, I remember what the problem was: if one of the
javascript files fails to load (*) I get a messagebox with the exception
(**) instead of entering the catch part of my try statement, that's why
I added the check both for rtl and QRCode (here commented out just to
test the problem).
<script>
//if (typeof rtl === 'undefined' || typeof QRCode === 'undefined') {
// console.log('rtl o QRCode no definidos, recargo pagina');
// setTimeout(function() { location.reload(); }, 5000);
//} else {
try {
rtl.run();
} catch(err) {
console.log('error '+err.message+', recargo pagina');
setTimeout(function() { location.reload(); }, 5000);
}
//}
</script>
I'd like the exception to be propagated to the outer code so my
try..catch would work.
(*) to quickly test I just removed one of the files from the server, but
in real life, if I'm unlucky enough, the server could be restarting
right after loading the html, before loading the extra js and be ready
again to load the pas2js application.
(**) and with edge in kiosk mode not even that
Bye
--
Luca
More information about the Pas2js
mailing list