oficina / slides Public

saving.mjs: a state poll that fails is "not yet", not the end of the run

A throw from view() ended every remaining scenario with nothing explained,
the one time the explanation is wanted. It now returns null and settle
keeps polling to its ceiling, as the WKWebView harness already did
(Claude Fable on Docs #98).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 72067998cf3f97a3801eef2424b3bfe497ead505 parent ad9bcb2
1 file changed, +11 −4
  • fixtures/engines/saving.mjs +11 −4

CI passed — run details

diff --git a/fixtures/engines/saving.mjs b/fixtures/engines/saving.mjs
index f491092..d4a1108 100644
--- a/fixtures/engines/saving.mjs
+++ b/fixtures/engines/saving.mjs
@@ -44,10 +44,16 @@ const CEILING_MS = 20000
// view is the test server's side of a document: its text, and every save
// that reached it. Asked from here, not from the page, which is the one
// whose requests are being refused.
+// A poll that fails is "not yet", as in the WKWebView harness: throwing
+// here would end every scenario left, with nothing explained, at the one
+// time the explanation is wanted (Claude Fable on Docs #98).
const view = async (sqid) => {
- const r = await fetch(config.origin + config.state + sqid)
- if (!r.ok) throw new Error(`${config.state}${sqid}: ${r.status}`)
- return r.json()
+ try {
+ const r = await fetch(config.origin + config.state + sqid)
+ return r.ok ? await r.json() : null
+ } catch {
+ return null
+ }
}
const holds = (text, want) => want.split(/\s+/).every((w) => text.includes(w))
@@ -65,7 +71,8 @@ const retried = (trace) => {
async function settle (sqid, since, watchMs, done) {
for (;;) {
const ms = Date.now() - since
- if (ms >= watchMs && done(await view(sqid))) {
+ const v = ms >= watchMs ? await view(sqid) : null
+ if (v && done(v)) {
// The page's console lines from just before are still on their way.
await pause(250)
return { settled: true, ms }