Repository navigation
fix(sync, editor): retryable rejects resent, sync resumes after a lost pull, no double move, typing kept on remote changes, tagged blocks saved - #13909
Conversation
| (let [before-cursor (subs value 0 (min (count value) (or cursor-pos (count value))))] | ||
| (boolean (re-find #"#(?:\[\[[^\]]*|\S+)$" before-cursor)))) |
There was a problem hiding this comment.
🔍 End-of-line URL fragments still defer auto-save
With the cursor after https://example.com/#anchor, typing-tag-at-cursor? matches #anchor and skips the timer save. The new visibility handler provides a separate save opportunity, but the claimed URL-fragment auto-save behavior needs checking.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
editor.cljs:2045 (URL fragment at the cursor). Right: |
82efb32 to
75092ef
Compare
75092ef to
e3a372e
Compare
|
Observed on installed 2.0.2 / 533ac43: native status remained local-tx 252 for 20m27s while remote-tx advanced 317→553 and pending-server 65→301. Every capture reported ws-state open, last-error null and no pending local/assets; later checksums differed. Graceful desktop termination/relaunch reached 553/553, zero queues and matching checksums on both devices. This resembles section 2's user-visible symptom, but we have no proof of a lost pull marker or validation of this PR against the incident. Sanitized status timeline available. |
|
Thanks, that timeline helps. With the socket open and no error the whole time, section 2 alone would not have healed it: it clears the pending-pull marker only when the socket closes or a new one opens, and a pull reply lost on a socket that stays open left the marker set, so every later pull from local-tx 252 was dropped as a duplicate until the relaunch. 8c1d452 (section 2b) records when the pending pull was sent and sends a pull from the same t again after 30 s without a reply; |
|
@yuxi-liu-wired Thanks for adding 8c1d452. I investigated the retained evidence and ran a controlled reproduction. I cannot recover a historical 1. Original incident: status timeline, not a continuous transport traceThe stalled desktop was NixOS, with a macOS client on the same synced graph. The reported installed release/revision was 2.0.2 beta /
Every listed status snapshot reported At 17:04:08.428, the identified NixOS desktop was gracefully terminated with SIGTERM and relaunched through its installed launcher using 2. Newly recovered worker log: closes/reconnects between the snapshotsI retrieved the original NixOS worker's retained The This qualifies my earlier comment and the incident attribution in section 2b: “open at every capture” must not be read as “open and error-free throughout the whole interval.” Section 2's marker surviving a close/reconnect remains relevant to this incident; the available evidence cannot distinguish it from an unanswered pull during an open interval, or establish either as the cause. I have not established a server-side loss, a blocked receive queue, or another consumer failure. I am also not attributing this incident to co-occurring markdown-mirror errors or to a separate, later macOS TLS-trust failure. 3. Controlled reproduction using the installed compiled clientThis was a new synthetic experiment on macOS, not recovered incident frames and not an end-to-end graph-sync test:
The observed sequence, using elapsed milliseconds from the fixture's monotonic start: Assertions passed: one initial pull, no resend after more than 31 seconds despite the subsequent This demonstrates the installed client's indefinite same- 4. Capture capability for another occurrenceIn a separate isolated smoke, an explicit startup That establishes a practical startup instrumentation path, not attachment to the existing worker or timing-neutral behavior on a live graph. No live worker was restarted or instrumented during this investigation. A future diagnostic capture would need to start before the relevant worker's first sync exchange and retain socket close/reconnect boundaries as well as Bottom line: the original incident still has an unconfirmed mechanism; intervening reconnects are now confirmed; and the installed-client unanswered-pull behavior has been reproduced with a captured message sequence. All evidence needed to interpret those distinctions is included above rather than linked to private/local files. |
|
Thanks for the worker log and the reproduction against the installed client. The four close/reconnect cycles change the reading: in 2.0.2 the pending-pull marker survives a close and the reconnect reuses the client map, so a pull lost with any of those sockets blocks every later pull from 252 until a restart. That is section 2's path. The relaunch healing it fits too, since it builds a new client map. 2b is the open-socket variant that your loopback run shows directly. Your reading of 8c1d452 is right: the expiry was only checked on the next |
620a530 to
ba5d060
Compare
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
ba5d060 to
a186313
Compare
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
a186313 to
51aebbc
Compare
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
51aebbc to
096793c
Compare
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
096793c to
14ff90d
Compare
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
14ff90d to
ef9f667
Compare
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
…ds it again An edit (a new block, a paste, a property change) disappeared from the page a moment after it was made when the sync server failed on a storage error while applying it. It was never uploaded, and no other device got it. When the server had in fact committed the tx and failed afterwards, every inflight edit was rolled back locally, and uploads stalled until another client's change arrived. The server answers such failures with `tx/reject` and `:retryable true` (and `"snapshot upload in progress"` while a graph upload runs), but the client never read the flag: `handle-tx-reject!` rolled back the failed tx, or every inflight tx when the reply carried no tx ids, and marked them failed, so they were never resent. A retryable reject now marks the txs the server confirmed as sent, keeps the others pending, clears inflight and sends them again: after a pull when the reject's t moved past ours (the server stored something), else after one second. A non-retryable reject is handled as before. Test: `frontend.worker.sync.sync-recovery-test` (retryable reject with a failed tx id, retryable reject after the server's commit, snapshot upload in progress).
After a network blip or a server-side socket close, sync silently stopped: local edits piled up as pending and never uploaded, and other devices' edits never arrived. Reconnecting, coming back online or showing the tab did not heal it; only a graph switch or reload did. `request-pull!` sends one pull per `since` and remembers it in `:pending-pull-since` until `pull/ok` clears it. When the socket closed before the reply, the marker stayed, and the reconnect kept the same client map. Every later pull from the same t (from `hello`, `changed` or a stale reject) was then taken for a duplicate and never sent, and uploads wait for the pull. The marker is now cleared when the socket closes (`onclose` and the stale-socket check) and when a new socket opens, before `hello`. Test: `frontend.worker.sync.sync-recovery-test` (ws close, stale socket close).
…ayed The user pressed move up (Alt+Shift+Up) once while the network hiccuped. After the reconnect the block had moved up two places, on this device and on every other one. The server applied the upload but its `tx/batch/ok` was lost with the socket, so the tx stayed pending. The next pull returned that same tx, but `handle-pull-ok!` dropped the `:tx-id` the server sends. `apply-remote-tx-with-local-changes!` then reversed the pending tx, applied the pulled copy, and replayed the pending tx on top. A relative op such as `:move-blocks-up-down` moved the block again, and the replay stayed pending and was uploaded, so the server applied the second move too. `handle-pull-ok!` now keeps each pulled tx's `:tx-id`. A pending tx whose id is among the pulled txs is reversed as before, but not replayed, and is marked as sent. Test: `frontend.worker.sync.sync-recovery-test` (pull/ok keeps the tx id, a pulled own move up is applied once).
…longer resets the editor Typing in a block of a synced graph, the textarea suddenly reverted to the block's last saved text and the cursor jumped when a collaborator (or the user's other device) added a child under the block, set a property on it, or edited a page it references. Everything typed since the last auto-save was lost, silently. Since fb1047d the UI pipeline puts the title of the editing block into the editor whenever a remote tx's render delta carries that block. The delta also carries a block whose children, properties or referenced entities changed; its title is then the unchanged saved title, which differs from the unsaved text in the editor. Before that commit only an added `:block/title` datom of the editing block did this. `invoke-hooks` now reads the editing block's title from the renderer store before applying the delta, and the editor content is replaced only when the delta's title differs from it, i.e. when the tx changed the title. Test: `frontend.modules.outliner.pipeline-editing-title-test`.
…en the page is hidden Editing a block that contains a hashtag (`#task`, `#project`, a URL with `#anchor`), then reloading, minimizing, switching away or (on mobile) sending the app to the background without leaving the block first, lost everything typed in the block: when the user came back it held the text it had before editing started. The auto-save timer skipped every block whose text matched `#\S+`, meant to avoid creating a tag page for a half-typed tag, so a block that already held a complete tag was never auto-saved. Nothing saved the editor when the page went away either. The timer now holds the save back only while a tag is being typed at the cursor (`#ta`, `#[[my ta`); a tag elsewhere in the block no longer stops it. The app also saves the editing block, with the textarea's text, when the document becomes hidden (`visibilitychange`), which is when a mobile OS may kill the backgrounded app. Test: `frontend.handler.editor-unsaved-text-test` (auto-save with a complete tag and with a tag being typed, save when hidden).
…ing by paste or arrow Block "foo": the user typed "x" and paused, so "foox" was auto-saved, then pressed Backspace (the text is "foo" again) and within the auto-save delay pasted blocks or pressed ArrowDown into the block's property row or comments area. The editor moved on and the block stayed "foox": the deletion was lost silently. `paste-blocks` and `move-cross-boundary-up-down` decided whether the editor held unsaved text by comparing it with the title in `:editor/block`, which is captured when editing starts and not updated by later saves. Text equal to the start text looked saved, so neither saved it, and the editor was switched without a save. Both now compare the editor text with the block's last saved title, as `save-block-if-changed!` does: a save still in flight, else the renderer snapshot. Test: `frontend.handler.editor-unsaved-text-test` (paste after an edit undone back to the start text).
…-save The auto-save skips a block while a tag is being typed at the cursor, so a half-typed `#ta` does not become a tag. The check matched any `#` before the cursor, so a block ending in a URL with a fragment (`https://example.com/#anchor`) was never auto-saved while the cursor stayed there. A tag starts at the beginning of the text or after whitespace; a `#` inside a word is not one. The check now requires that. Test: `auto-save-runs-in-a-block-that-holds-a-tag-test` gains the URL-fragment-at-the-cursor case.
The retryable-reject tests in `frontend.worker.sync.sync-recovery-test` built their graph without `:logseq.kv/graph-remote?`, so it was a local graph that only happened to have a client-ops store. Today every local tx gets a client-op row anyway, but logseq#13786 stops writing those rows for a graph that does not sync (no remote flag, no remote graph id). With both changes, the deleted block's tx had no row: `pending-txs` was empty, the reject carried no tx id, and the tests read an undefined row (`Cannot read properties of undefined (reading 'pending')`). A tx/reject only reaches a graph that syncs, so `setup-parent-child` now sets the remote flag, as upload and download do. The tests pass on this branch alone and merged with fix/db-page-delete-combined.
The pending-pull marker made every later pull from the same t a duplicate until pull/ok cleared it. Section 2 of this PR clears it when the socket closes, but a reply lost while the socket stays open kept it forever: the local t stopped while the server's moved on, with the socket open and no error, until a restart (a field report on 2.0.2: 20 minutes). The client now records when the pending pull was sent, and a pull from the same t is sent again once 30 s have passed with no reply.
The 30 s expiry of 8c1d452 was only checked when the next pull was requested, so on a graph where no later `changed` arrives a lost pull reply still left the local t behind. Each sent pull now schedules a check pull-reply-timeout-ms later that sends it again while the same pull is still waiting; a pull/ok or a newer pull makes the check a no-op. In node the timer is unref'd so it does not keep the worker alive.
ef9f667 to
c016fba
Compare
The undo's render delta puts the undone text into the editor before the undo's result reaches the history handler; the cursor restore then pulled the block and called edit-block!, which loads it again, and moved the cursor over whatever the user had selected in between: Mod+a then Backspace right after Mod+z deleted one character (cursor-boundaries-word-motion-and-kill-test, which fails the same way on master under load). The undo/redo snapshots the editing block, its text and selection before the worker request. The restore edits the block only if the user did nothing there meanwhile (the editor holds the snapshot, or the undone text with the cursor at its end), checked after the pull and once more through a one-time edit guard right before edit-block! moves the editor. The edit-block! call is master's, unchanged. This replaces 7095560, whose pipeline hold-back of the editing title conflicted with logseq#13909's change to the same pipeline function.
Six fixes from a review of the sync client and the editor's save path, one commit each. Every test is in a new namespace and fails on master.
1. A reject the server marks retryable keeps the edit and sends it again
What the user sees. An edit (a new block, a paste, a property change) disappears from the page a moment after it was made. It is never uploaded and no other device gets it. When the server had in fact committed the tx, every inflight edit is rolled back locally and uploads stall until another client's change arrives.
Cause. On a failure that is not a data error (e.g. a storage error after a write), the server answers
tx/rejectwith:retryable true; it sends"snapshot upload in progress"while a graph upload runs. The client never read the flag:handle-tx-reject!rolled back the failed tx, or every inflight tx when the reply carried no ids, and marked them failed, so they were never resent.Change. A retryable reject (or
"snapshot upload in progress") marks the txs the server confirmed as sent, keeps the others pending, clears inflight and sends them again: after a pull when the reject's t moved past ours, else after one second. Non-retryable rejects are handled as before.Test.
frontend.worker.sync.sync-recovery-test: retryable reject with a failed tx id, retryable reject after the server's commit, snapshot upload in progress. On master the edit is rolled back and marked failed.2. A pull lost to a ws drop no longer stops sync until restart
What the user sees. After a network blip or a server-side socket close, sync silently stops: local edits pile up as pending, other devices' edits never arrive. Reconnecting, coming back online or showing the tab does not heal it; a graph switch or reload does.
Cause.
request-pull!remembers the pull it sent in:pending-pull-sinceuntilpull/okclears it. When the socket closed before the reply, the marker stayed and the reconnect reused the client map, so every later pull from the same t was taken for a duplicate and never sent; uploads wait for that pull.Change. The marker is cleared when the socket closes (
oncloseand the stale-socket check) and when a new socket opens, beforehello.Test.
frontend.worker.sync.sync-recovery-test: after a close, achangedsends the pull; the stale-socket check clears the marker. On master no pull is sent.3. A pending tx the pull shows the server applied is not replayed
What the user sees. Move up (Alt+Shift+Up) pressed once during a network hiccup: after the reconnect the block has moved up two places, on every device.
Cause. The server applied the upload but its ack was lost with the socket, so the tx stayed pending. The next pull returned that tx, but
handle-pull-ok!dropped the server's:tx-id, andapply-remote-tx-with-local-changes!reversed the pending tx, applied the pulled copy and replayed the pending tx on top.:move-blocks-up-downis relative, so the block moved again, and the replay was uploaded.Change.
handle-pull-ok!keeps each pulled tx's:tx-id. A pending tx whose id is among the pulled txs is reversed as before but not replayed, and is marked as sent.Test.
frontend.worker.sync.sync-recovery-test: pull/ok keeps the tx id; a pulled own move up is applied once and leaves nothing pending. On master the block ends up first and the move stays pending.4. A remote change that keeps the editing block's title no longer resets the editor
What the user sees. Typing in a synced graph, the textarea reverts to the block's last saved text and the cursor jumps when someone adds a child under the block, sets a property on it, or edits a page it references. Everything typed since the last auto-save is lost.
Cause. A regression from fb1047d: the UI pipeline puts the editing block's title into the editor whenever a remote render delta carries the block. The delta also carries blocks whose children, properties or references changed, with the unchanged saved title. Before, only an added
:block/titledatom did this.Change.
invoke-hooksreads the editing block's rendered title before applying the delta and replaces the editor content only when the delta's title differs from it.Test.
frontend.modules.outliner.pipeline-editing-title-test: a delta with the saved title keeps the typed text; a delta with a new title still replaces it.5. Auto-save blocks that hold a tag, and save the editor when the page is hidden
What the user sees. Editing a block that contains a hashtag (
#task, a URL with#anchor), then reloading, minimizing, switching away or sending the mobile app to the background without leaving the block, loses everything typed in it.Cause. The auto-save timer skipped every block matching
#\S+(meant to avoid a tag page for a half-typed tag), so a block holding a complete tag was never auto-saved, and nothing saved the editor when the page went away.Change. The timer holds the save back only while a tag is being typed at the cursor (
#ta,#[[my ta). The app saves the editing block, with the textarea's text, when the document becomes hidden (visibilitychange).Test.
frontend.handler.editor-unsaved-text-test: auto-save runs with a complete tag and with a URL anchor, not with a tag being typed; hiding the page saves with:flush-input? true.6. An edit undone back to its start text is saved when leaving by paste or arrow
What the user sees. Block "foo": type "x", pause ("foox" is auto-saved), press Backspace, then within the auto-save delay paste blocks or press ArrowDown into the property row or comments. The block stays "foox".
Cause.
paste-blocksandmove-cross-boundary-up-downcompared the editor text with the title in:editor/block, captured when editing started and not updated by later saves, so text equal to the start text looked saved.Change. Both compare with the block's last saved title, as
save-block-if-changed!does: a save still in flight, else the renderer snapshot.Test.
frontend.handler.editor-unsaved-text-test: paste after an edit undone back to the start text saves "foo". On master nothing is saved.Test setup: the sync-recovery tests run on a graph that syncs
The graph in
frontend.worker.sync.sync-recovery-testhad no:logseq.kv/graph-remote?, so it was a local graph that happened to have a client-ops store. On master every local tx still gets a client-op row, but #13786 stops writing those rows for a graph that does not sync. With both PRs merged the deleted block's tx had no row, the reject carried no tx id, and three tests read an undefined row. Atx/rejectonly reaches a graph that syncs, sosetup-parent-childnow sets the remote flag, as upload and download do (7a38ffd). Test-only; the namespace passes on this branch alone and merged with #13786.2b. A pull whose reply is lost on an open socket is sent again after 30 s
What the user sees. As in section 2, sync stops: the local t stays put while other devices' changes pile up on the server, until a restart. Reported on 2.0.2 in comments here (local t 252 for 20 minutes while the server went 317 to 553; the worker log shows four close/reconnect cycles in that time, which section 2 covers). The reporter reproduced the open-socket case on the installed 2.0.2 client with a server that withholds
pull/ok: one pull, then none for over 31 s whilechangedkept arriving.Cause. Section 2 clears the pending-pull marker when the socket closes or a new one opens. A reply lost while the socket stays open never closes it, so the marker stayed and every later pull from the same t was dropped as a duplicate.
Change. The client records when the pending pull was sent (
:pending-pull-sent-at). Each sent pull schedules a checkpull-reply-timeout-ms(30 s) later that sends it again if the same pull is still waiting, so it recovers also on a graph where no laterchangedarrives; apull/okor a newer pull turns the check into a no-op.request-pull!likewise sends a pull from the same t again once 30 s have passed. In node the timer is unref'd.Test.
frontend.worker.sync.pull-reply-timeout-test: the timer resends an unanswered pull and sends nothing once the reply came; achanged31 s after an unanswered pull sends it again, 1 s after does not. The timer and expiry tests fail without the change (8c1d452, 620a530);sync-recovery-teststill passes.