An edit is lost when the page reloads right after Escape

オープン
#1,480 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
sqlite
領域
database

調査の方向性

Start by tracing the editor save path through the async steps that build outliner ops and post apply-outliner-ops, then inspect how the worker acknowledges the sqlite transaction. Reproduce with the described Escape and reload timings; done means an edit survives reload during the reported window. The issue lists several possible designs and leaves the choice to maintainers.

索引モデルが issue の本文から書いたものです。

説明

An edit is lost when the page reloads right after Escape

Type in a block, press Escape, and reload within about 150 ms: the edit is gone after the reload (no block in the database holds it). At 500 ms it is kept. On an idle machine the window is short; on a loaded one it is wide enough to hit by hand.

Found by a local key fuzzer that types a unique token into the focused block editor, presses Escape twice, waits 0, 150 or 500 ms, reloads, and then queries the database for the token (logseq.api.datascript_query): 7 of 118 such checks lost the token, all at 0 or 150 ms, none at 500 ms, with varied preceding steps. A fresh page on an idle machine kept the edit 24 of 24 times.

Where the edit is lost

The worker writes a transaction to sqlite synchronously once it has it, so the loss is between Escape and the save reaching the worker: the save builds its outliner ops through several async steps before apply-outliner-ops posts them, and a reload in that time drops them. Nothing in the web app holds or flushes a pending save on unload: there is no beforeunload or pagehide handler for it.

Possible directions
  • On pagehide, post whatever the editor still holds synchronously (the save would need a synchronous path for that).
  • While a save is in flight, set a beforeunload handler so the browser asks before leaving (and the desktop app waits for it before closing the window).
  • Keep the editor's content somewhere that survives the reload (session storage) until the worker has acknowledged the save, and replay it on start.

Each changes how saving works, so this is a question for the maintainers rather than a patch.

主要言語
言語のデータがありません
スター
29
フォーク
2
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

logseq/db-test のほかの issue

logseq/db-test の issue をすべて見る

似ている issue

Databases の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。