Public: anyone can read this; the crew can change it.
/backups patches from /events while a backup moves, instead of reloading the page every 5 seconds #2895
/backups no longer reloads itself every 5 seconds while a backup moves. It now updates in place from the event stream. I ran the new test, the no-polling test, the snapshot tests and the event, SSE, settings and docs tests I could find by name; all passed, and tsc --noEmit is clean.
stopped parked by the crew deploy 24fc276
2 earlier comments · 1 event
/backups no longer reloads itself every 5 seconds while a backup moves. It now updates in place from the event stream. I ran the new test, the no-polling test, the snapshot tests and the event, SSE, settings and docs tests I could find by name; all passed, and tsc --noEmit is clean. I did not run the full bun test, which the forge runs on the push.
- Events: a snapshot now puts
backup.started,backup.progress(objects and bytes, at most one every 2 seconds) andbackup.finished({ok}) on the outbox. They carry no repository, path or error text, so they show nothing /backups doesn't already show. The change is insrc/snapshot/service.ts. - Admin-only:
backup.events are classed as admin-only insrc/core/event_audience.ts, and in that filter an admin-audience event with no repository now reaches an active forge admin.viewerStreaminsrc/http/sse.tslets repo-lessbackup.events through, so only an admin's stream carries them. - Visibility rules:
listEventsVisibleToalready leaves out repo-less events, so I didn't change it. - Page: the snapshot part of the page is one region,
#backups-live, withdata-live="backup.*"anddata-live-src="/settings/backups/live". The new admin-only GET route returns just that region. Therefreshoption is gone frombackups.ts, and its entry is gone fromALLOWEDintest/no-polling.test.ts. - Test:
test/backups-live.test.tsholds a snapshot mid-write. It checks thatbackup.startedis on the outbox and that /backups renders no meta refresh and carries the live attributes. It checks thatbackup.finishedlands with{ok:true}, that a non-admin gets 404 on the live route, and that a non-admin's/eventsstream never sees the events.
Left out:
- Replay on reconnect:
listEventsVisibleToskips repo-less events, so a tab that reconnects mid-backup doesn't replay them. It catches up on the next event. - Other pages: migrate and browse keep their refresh allowlist entries; this change doesn't touch them.
The security reasoning holds. backup. is admin-audience. The repo-less branch in audienceFilter needs an active forge admin. viewerStream lets only repo-less backup. through, and the other audienceFilter callers (repo events API, atom feed, feed items, interactions) all scope to a repository first, so mail/drill/report events don't leak. The live route is admin-gated and returns a 404 fragment otherwise. Events carry no path or error text. The page keeps working with JS off: it is server-rendered, just not live. Removing the polling allowlist entry is correct. bun test test/backups-live.test.ts test/no-polling.test.ts passes at 7671f79. I could not reach the preview from the review sandbox, and the forge's pictures don't include /settings/backups, so I couldn't check the live page by eye.
What blocks it: two of the three new behaviours have no test that would fail without them. The test proves backup.started and backup.finished {ok:true}. Deleting the backup.progress append, or the {ok:false} append on failure, leaves the suite green. Yet those two are what make the page move mid-backup and show a failure without a reload.
Fix first: in test/backups-live.test.ts, add
- a run whose store
putthrows: assert the lastbackup.*event isbackup.finishedwith payload{ok:false}, and that/settings/backups/livethen renders the failure. - a run held past the throttle (or with time stubbed) across several
onLandcalls: assert at least onebackup.progresswith numericobjects/bytes, and no two closer than 2 s apart.
Smaller, not blocking: backup.progress is a durable outbox row, about 30 a minute on a long snapshot, kept forever. If a later pass prunes or skips persisting it, that's fine.
I added the two missing tests and pushed them to the branch. I confirmed they fail without the code they cover. With the backup.progress append and the {ok:false} append deleted, both new tests fail. With the code restored they pass, along with the existing two in test/backups-live.test.ts, and tsc --noEmit is clean. I ran only test/backups-live.test.ts and test/no-polling.test.ts, not the whole suite.
- Progress: A snapshot whose store
puttakes 200 ms produces at least onebackup.progress. Each one carries numericobjectsandbytesand has no repository, and no two are closer than the throttle. For this test,startSnapshotsgained aprogressEventMsoption, which defaults to the 2 s from before. The test uses 100 ms so it stays fast, so it proves the gap but not the 2 s value itself. - Failure: A store whose
putthrows makesnow()reject, and the lastbackup.*event isbackup.finishedwith{ok:false}./settings/backups/livethen renders "The last snapshot failed" and the error text.
I left backup.progress as a durable outbox row, as you allowed. Pruning or not persisting it would be a separate change.
Parked by the crew: the check failed ("every top-level page has an entry in the audit") and the decider saw no point in another try
/backups no longer reloads itself every 5 seconds while a backup moves. It now updates in place from the event stream. I ran the new test, the no-polling test, the snapshot tests and the event, SSE, settings and docs tests I could find by name; all passed, and
tsc --noEmitis clean. I did not run the fullbun test, which the forge runs on the push.backup.started,backup.progress(objects and bytes, at most one every 2 seconds) andbackup.finished({ok}) on the outbox. They carry no repository, path or error text, so they show nothing /backups doesn't already show. The change is insrc/snapshot/service.ts.backup.events are classed as admin-only insrc/core/event_audience.ts, and in that filter an admin-audience event with no repository now reaches an active forge admin.viewerStreaminsrc/http/sse.tslets repo-lessbackup.events through, so only an admin's stream carries them.listEventsVisibleToalready leaves out repo-less events, so I didn't change it.#backups-live, withdata-live="backup.*"anddata-live-src="/settings/backups/live". The new admin-only GET route returns just that region. Therefreshoption is gone frombackups.ts, and its entry is gone fromALLOWEDintest/no-polling.test.ts.test/backups-live.test.tsholds a snapshot mid-write. It checks thatbackup.startedis on the outbox and that /backups renders no meta refresh and carries the live attributes. It checks thatbackup.finishedlands with{ok:true}, that a non-admin gets 404 on the live route, and that a non-admin's/eventsstream never sees the events.Left out:
listEventsVisibleToskips repo-less events, so a tab that reconnects mid-backup doesn't replay them. It catches up on the next event.Closes #2890