Report every failed fetch instead of discarding it
Twenty-four fetch chains ended in an empty catch, which is not error handling but error deletion: the request fails, nothing renders, nothing is logged, and the surface sits on Loading forever. That is how the mesh chat's ReferenceError read as a slow load for as long as it did.
This commit is contained in:
@@ -92,6 +92,37 @@ function vvEscAttr(s) {
|
||||
.replace(/</g,'<').replace(/>/g,'>');
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════════════════════════
|
||||
// What a failed fetch says.
|
||||
//
|
||||
// Every fetch in this plugin used to end in `.catch(() => {})` — 24 of them. That is not error
|
||||
// handling, it is error deletion: the request fails, nothing renders, nothing is logged, and the
|
||||
// surface either sits on "Loading…" forever or silently keeps showing stale numbers. The mesh chat
|
||||
// spent an unknown amount of time "taking a minute to load" because a ReferenceError was thrown on
|
||||
// every render and swallowed here; the fault named itself the moment a catch reported it.
|
||||
//
|
||||
// Console always, because a poller that drops one tick should not shout on screen. A target
|
||||
// element when the caller has one, because a panel that will otherwise never fill has to say why.
|
||||
//
|
||||
// Global for the same reason vvEscHtml is: pages/*.php are included one at a time and each would
|
||||
// otherwise carry its own copy, which is the arrangement that lets two of them drift.
|
||||
function vvFetchErr(where, e, el) {
|
||||
const msg = (e && e.message) ? e.message : String(e || 'request failed');
|
||||
try { console.warn('[varaverk] ' + where + ' — ' + msg, e); } catch (_) {}
|
||||
if (el) {
|
||||
const n = (typeof el === 'string') ? document.getElementById(el) : el;
|
||||
if (n) { n.textContent = where + ' failed: ' + msg; n.style.color = '#a05a2c'; }
|
||||
}
|
||||
}
|
||||
|
||||
// Throws on a non-2xx instead of handing HTML to JSON.parse. Unraid answers an expired session
|
||||
// with a 302 to the login page, so without this the reported error is "Unexpected token '<'",
|
||||
// which names the symptom and hides the cause.
|
||||
function vvJson(r) {
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
return r.json();
|
||||
}
|
||||
|
||||
// A URL about to be put in href/src or handed to window.open. Anything that is not plainly http,
|
||||
// https or a site-relative path becomes empty — javascript: is the one that matters, and an
|
||||
// allowlist is the only way to say that without chasing encodings. include/docs.php applies the
|
||||
|
||||
Reference in New Issue
Block a user