Chat: no time limit on the retry (slow connections)
Browse files- chat/chat.js +3 -2
chat/chat.js
CHANGED
|
@@ -282,9 +282,10 @@ function attachAudit(evidence) {
|
|
| 282 |
|
| 283 |
// JSON from this site. A request can stall behind the browser's cache lock when the page was reloaded while it was
|
| 284 |
// downloading (the desktop app does that when it opens the chat), so give up after a few seconds and retry past the cache.
|
| 285 |
-
|
|
|
|
| 286 |
for (const mode of [cache, 'reload']) {
|
| 287 |
-
const ctl = new AbortController(); const timer = setTimeout(() => ctl.abort(), timeout);
|
| 288 |
try {
|
| 289 |
const r = await fetch(p, { cache: mode, signal: ctl.signal });
|
| 290 |
if (!r.ok) throw new Error(`${p}: ${r.status}`);
|
|
|
|
| 282 |
|
| 283 |
// JSON from this site. A request can stall behind the browser's cache lock when the page was reloaded while it was
|
| 284 |
// downloading (the desktop app does that when it opens the chat), so give up after a few seconds and retry past the cache.
|
| 285 |
+
// The retry has no time limit, so a slow connection still gets there.
|
| 286 |
+
async function getJson(p, { timeout = 5000, cache = 'default' } = {}) {
|
| 287 |
for (const mode of [cache, 'reload']) {
|
| 288 |
+
const ctl = new AbortController(); const timer = mode === 'reload' ? null : setTimeout(() => ctl.abort(), timeout);
|
| 289 |
try {
|
| 290 |
const r = await fetch(p, { cache: mode, signal: ctl.signal });
|
| 291 |
if (!r.ok) throw new Error(`${p}: ${r.status}`);
|