Page: catch background fetches, no HTML in errors, a trace ends after a quiet minute (#219)
The page reported NetworkError rejections from the live update's list refresh and the first feed load, which had no catch, whenever the network was gone (a laptop asleep). A Cloudflare 502 page became a request's error message, since api() used whatever body came back. And the trace id lived until the next tap, so background requests nine hours apart shared one trace. The id now ends after a minute without a request; a play's position saves, every ten seconds, keep it going. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,6 +68,18 @@ for (const [name, fn] of drive) {
|
||||
}
|
||||
}
|
||||
|
||||
// A trace is one tap's (#219): the same id while requests keep coming, a new one after a quiet
|
||||
// minute, so a refresh hours later is not filed under the last tap.
|
||||
if (PAGE === 'index.html') {
|
||||
const id = () => ctx.traceparent().split('-')[1];
|
||||
vm.runInContext('Date.now = (n => () => n)(1e12)', ctx);
|
||||
const first = id();
|
||||
vm.runInContext('Date.now = (n => () => n)(1e12 + 30_000)', ctx);
|
||||
if (id() !== first) { console.error('FAIL: a trace ended 30 s into a tap'); process.exit(1); }
|
||||
vm.runInContext('Date.now = (n => () => n)(1e12 + 120_000)', ctx);
|
||||
if (id() === first) { console.error('FAIL: a trace outlived a quiet minute'); process.exit(1); }
|
||||
}
|
||||
|
||||
// theme.ts keeps the Settings theme controls in step when Settings is open, and looks before it
|
||||
// touches them. The admin page has no Settings, so those are the ones it may ask for and not find.
|
||||
const OPTIONAL = new Set(['#stheme', '#smode', '#smodefield']);
|
||||
|
||||
Reference in New Issue
Block a user