Skip to content

fix(collab): build-before-delete on replace (#342) + fail-loud content write when Redis off (#344) - #33

Merged
PMQ9 merged 1 commit into
wiki-v2from
fix/343-empty-content-and-collab-writes
Sep 17, 2026
Merged

PMQ9 merged 1 commit into
wiki-v2from
fix/343-empty-content-and-collab-writes

Conversation

@PMQ9

@PMQ9 PMQ9 commented Sep 17, 2026

Copy link
Copy Markdown

Two pre-existing content-write defects on the collaboration path, both surfaced while tracing docmost#282 (ADR 0019). Fork half of the paired fix; the super-repo PR (cccvu/wiki-v2) carries docmost#343 + the submodule bump.

docmost#342 — a replace could WIPE the page on a build failure

applyContentOperation emptied the Yjs fragment before building the new document from the request body. If TiptapTransformer.toYdoc threw (content that passed jsonToNode but the Yjs transformer rejects), the connection's closing disconnect() store persisted the emptied fragment — the page was wiped while the request also failed.

Fix: build the new state first (toYdoc + encodeStateAsUpdate), then delete+apply. A conversion failure now aborts before any mutation, so the original content survives and the closing store re-persists it unchanged. Shared by the ordinary updatePageContent handler and the docmost#282 conditional write.

docmost#344 — content writes silently no-op with COLLAB_DISABLE_REDIS

Custom collab events route only through the RedisSync extension, so in single-node standalone mode handleYjsEvent('updatePageContent') returned undefined and PageService.update ignored it: a REST//v1 content write returned 200 while persisting nothing.

Fix (narrowest boundary): handleYjsEvent throws for updatePageContent when Redis is disabled. The supported standalone mode still boots, interactive editing (direct Hocuspocus path) is untouched, and the docmost#282 seams keep their fail-closed undefined contract. Investigation confirmed COLLAB_DISABLE_REDIS (isStandalone) is a legitimate upstream mode, so it is preserved rather than removed.

Tests

🤖 Generated with Claude Code

… content write when Redis off (docmost#344)

Two pre-existing content-write defects on the collaboration path, both found while
tracing docmost#282 and both able to lose or silently drop a page's content.

docmost#342 — a content `replace` emptied the Yjs fragment BEFORE building the new document
from the request body. If `TiptapTransformer.toYdoc` threw (a body that passed
`jsonToNode` but the Yjs transformer rejects), the connection's closing store persisted
the emptied fragment: the page was WIPED while the request also failed. Build the new
state first, then delete+apply — a conversion failure now aborts before any mutation and
the original content survives. Shared by the ordinary `updatePageContent` handler and the
docmost#282 conditional write.

docmost#344 — custom collab events route only through the RedisSync extension, so with
COLLAB_DISABLE_REDIS (single-node standalone) `handleYjsEvent('updatePageContent')`
returned undefined and `PageService.update` ignored it: a REST/`/v1` content write
returned 200 while persisting nothing. Fail that one un-routable write loudly instead.
Narrowest boundary: the supported standalone mode still boots, interactive editing (direct
Hocuspocus path) is untouched, and the docmost#282 seams keep their fail-closed `undefined`
contract.

Tests: build-before-delete leaves the fragment intact on a throwing toYdoc; the gateway
guard throws for updatePageContent with Redis off, stays quiet for best-effort events, and
routes normally with Redis on. UPSTREAM_MODIFICATIONS.md seams #2/#3 updated.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@PMQ9
PMQ9 force-pushed the fix/343-empty-content-and-collab-writes branch from a9702f3 to 97f21d4 Compare September 17, 2026 03:03
@PMQ9
PMQ9 merged commit 90fdd9e into wiki-v2 Sep 17, 2026
@PMQ9
PMQ9 deleted the fix/343-empty-content-and-collab-writes branch September 17, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant