oficina / docs Public

Docs: saving never stops while a link is loading, and a stop closes the streams

WebKit refuses every ordinary fetch a page starts while its main frame
waits for a navigation's answer: the promise rejects at once with "Load
failed" and nothing is sent. The page stays on screen and editable, and a
navigation answered with a download, or not at all, never takes it away.
Every save then read as a network failure: "Trouble saving. Retrying…",
retried four times a second, with no request reaching the edge, until a
reload ended the navigation. Measured in WKWebView and Playwright's
WebKit; Chromium sends them.

Saves now go keepalive (which WebKit still sends then, and which also
survives leaving), in batches of at most 32KiB. WebKit never settles a
keepalive save answered while its page is in the back/forward cache, so
the queue sends again on pageshow and gives up on any save unanswered
after 35s; fetch aborts one hung for 30s.

On SIGTERM the stream handler never ended, because a graceful shutdown
cancels no request: an open editor held the shutdown its full 10s and the
process exited 1 (12:49:18-29 today). Docs now drains its hub on the
signal, ending every stream at once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev e14d21ad021d97f2679d1042d10479a1c935e2d6 parent 0d00351
13 files changed, +1,085 −18
  • cmd/docs/main.go +15 −0
  • cmd/docs/shutdown_test.go +184 −0
  • fixtures/editor-entry.js +18 −7
  • fixtures/engines/saving-webkit.swift +142 −0
  • fixtures/engines/saving.mjs +49 −0
  • fixtures/save-queue.mjs +99 −3
  • fixtures/save-queue.test.mjs +113 −2
  • internal/docs/app.go +8 −0
  • internal/docs/hub.go +25 −1
  • internal/docs/saving_browser_test.go +356 −0
  • internal/docs/static/editor.f50559a532abe5ff.js +14 −0
  • internal/docs/stream.go +14 −3
  • internal/docs/stream_test.go +48 −2
cmd/docs/main.go

Loading diff…

cmd/docs/shutdown_test.go

Loading diff…

fixtures/editor-entry.js

Loading diff…

fixtures/engines/saving-webkit.swift

Loading diff…

fixtures/engines/saving.mjs

Loading diff…

fixtures/save-queue.mjs

Loading diff…

fixtures/save-queue.test.mjs

Loading diff…

internal/docs/app.go

Loading diff…

internal/docs/hub.go

Loading diff…

internal/docs/saving_browser_test.go

Loading diff…

internal/docs/static/editor.f50559a532abe5ff.js

Loading diff…

internal/docs/stream.go

Loading diff…

internal/docs/stream_test.go

Loading diff…