Skip to content

test(e2e): wait out editor races in delete-test - #13474

Merged
tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:test/e2e-delete-race
Sep 30, 2026
Merged

tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:test/e2e-delete-race

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What failed in CI

delete-test in clj-e2e/test/logseq/e2e/outliner_basic_test.clj (the "Test outliner-rtc" job) failed in 16 of the 151 failed Clojure E2E runs between 2026-09-17 and 2026-09-26: 2 on master and 14 on 12 pull request branches. By shape:

  • 7 runs: line 138 "b1" against nil, with the block count right (35220039274 on master, 35998744494 on master, 35426168039). The test read the editor before it mounted; fix: bump page updated-at on insert, move, and delete #13402 (1e07062b8) added the wait for it, and none of the later failures has this shape.
  • 4 runs: line 138 "b1" against nil and line 139 (= 1 4), nothing deleted (35854621210, 35865923401, 35871795647, 35899209725).
  • 3 runs: a Playwright TimeoutError waiting for .editor-wrapper textarea after the second delete (36224325707, 36229883846, 36244461624).
  • 2 runs: line 139 "b1" against "b2" and line 140 (= 1 2), b3 deleted and b2 left (36056373275, 36228900562).

The last 3 shapes come from 2 races in the test's steps. 1b33bbf40 (wait-edit-content "b1") polls for the final content and leaves both in place: after either race "b1" never comes.

The 2 races

The test types b1 to b4, deletes b4 (b/delete-blocks: util/exit-edit, then Backspace), presses Shift+ArrowUp twice to select b3 and b2, and deletes them.

  1. The delete of b4 puts b3 in editing only when the worker's answer comes back (run-edit-block-fn! in frontend/db/transact.cljs), and the test presses Shift+ArrowUp right away. In the probe on master, b3's editor mounted 34 to 535 ms after the Backspace (median 60 ms), and the first Shift+ArrowUp went down 106 to 170 ms after it. In 6 of 180 iterations the editor came after that first press (365 to 535 ms), and all 6 ended with b1 and b2 on the page and b2 in editing; no passing iteration had a late editor. The early press is lost. b3 was then selected alone, by the second Shift+ArrowUp or, when the editor came after both presses (5 of the 6), by the Escape of the second b/delete-blocks, so the second delete removed b3 only.
  2. util/exit-edit presses Escape, then presses it again if the editor is still visible. Escape saves the block before it leaves editing (escape-editing in frontend/handler/editor.cljs), so the editor stays for a while after the key: median 50 ms, up to 288 ms in the probe. In 8 of 180 iterations on master the editor left 119 to 205 ms after the first Escape: still visible at the second check, gone when the second Escape went down 212 to 220 ms after the first. That Escape reached the page, and the window keydown handler cleared b4's selection (hide-context-menu-and-clear-selection in frontend/components/container.cljs). Backspace then deleted nothing, the Shift+ArrowUp presses found neither an editor nor a selection, the second delete deleted nothing, and the wait for the textarea timed out with 4 blocks on the page. In 1 more iteration the second Escape went down while the textarea was still mounted, and the selection held.

What changes

  • delete-test waits for b3's editor, (util/wait-edit-content "b3"), before the Shift+ArrowUp presses.
  • util/exit-edit presses Escape once and waits up to 1 s for the editor to leave. It presses a second Escape only if the editor is still there after that wait, as when the first Escape closed a popup inside the editor.
(defn exit-edit
  []
  (when (get-editor)
    (k/esc)
    (when-not (editor-left? 1000)
      (when (get-editor)
        (k/esc))))
  (assert/assert-non-editor-mode))

exit-edit is called directly in 12 test namespaces, and through double-esc, b/open-last-block and b/delete-blocks in more. To see which calls rely on the second Escape, I ran the 20 namespaces of the e2e matrix other than rtc-basic-test (it logs in to a sync server), plus undo-redo-test, once with this change and a log line in exit-edit. All 21 passed. 125 calls pressed Escape, in 15 namespaces. In 124 of them the editor left within the wait, 107 to 135 ms after the call began, the key press included. 1 call pressed the second Escape: in disallow-adding-page-tag-to-normal-pages the editor stayed after the first Escape, and the second, 1.1 s later, ended editing. That test types " #Page", which opens the hashtag search, and while such an editor action is open editor-on-hide only stops the Escape (read in code). That is the case the second Escape is for, and it now costs up to 1 s. The rtc-extra namespaces need the sync server and were not run; read in code, they call exit-edit after typing, slash commands, undo and redo, the kinds of calls that left within the wait in this run.

Tests

Local runs against 1 web build of master 16c4ed1a0, made with the defines and --debug of clj-e2e.yml, served to 2 checkouts that differ only in clj-e2e: master and this branch. Runs alternated between them, up to 4 at a time on 1 machine.

  • A probe (not committed) that calls the tree's own outliner-basic-test/delete on a fresh page 20 times per run, and records in the page when each key went down and when the editor textarea mounted and left. 9 runs per build, 180 iterations each. Master: 166 pass, 6 end with b1 and b2 (race 1), 8 end with 4 blocks and no editor (race 2); 9 of 9 runs fail. This branch: 180 of 180 pass; 9 of 9 runs pass. The timings in the section above come from the master runs.
  • The outliner-basic-test namespace (26 tests), 15 runs per build. Master: 14 pass, and 1 failed move-up-down-test (a lost move, ["b1" "b3" "b4" "b2"]). This branch: 14 pass, and 1 failed delete-end-test (line 150: b2 in editing and 3 blocks). Read in code, ArrowUp at the first row saves the block through the worker before it moves editing to b2 (move-cross-boundary-up-down), so a Delete pressed in between lands at the end of b3. This PR leaves that test alone; it has no failure in the CI runs above. delete-test passed in all 30. It runs once per namespace run, and at master's probe rate of 14 failures in 180, about 3 in 10 sets of 15 runs have none, so these runs cannot separate the builds; the probe does.
  • On this branch, once each, the other namespaces that call exit-edit directly and run without a sync server: editor-basic-test (72 tests), commands-basic-test (31), reference-basic-test (5), library-basic-test (2), graph-navigation-basic-test (8), block-property-basic-test (14), view-basic-test (7), tag-basic-test (3), undo-redo-test (3). All pass.
  • clj-kondo on the 2 changed files: 0 errors, and the same 2 warnings as on master (wally.repl and Locator$FilterOptions unused in the ns form of util.clj).

Allow edits from maintainers.


Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@tiensonqin
tiensonqin merged commit 7ebc2eb into logseq:master Sep 30, 2026
11 checks passed
@yuxi-liu-wired
yuxi-liu-wired deleted the test/e2e-delete-race branch September 30, 2026 20:03
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.

2 participants