logseq / logseq/db-test

Desktop write API calls appear to stall for extended periods when the window is backgrounded

Open
#1,157 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
28
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Search first
  • I searched and no similar issues were found
What Happened?

I noticed the API was unstable in 2.0.1. When I dug in, I noticed:

  1. they were timeouts or complete hangs
  2. only writes were affected
  3. it only happened when the window was in the background or minimized
  4. sometimes writes would be applied after the window was back in the foreground.
Reproduce the Bug
  1. Launch the desktop app with the local HTTP API server enabled.
  2. Poll a write method (e.g. logseq.Editor.appendBlockInPage) on an interval — I used a script hitting it every 30s.
  3. Minimize the app window or switch away so it's backgrounded, and leave it idle for 10+ minutes (or let the machine idle-sleep and wake back up on its own).
  4. In my case, writes issued while the window was backgrounded either timed out client-side or resolved late, and a backlog would land in a burst once the window regained focus.
Expected Behavior

API functions would work whether the app was in the foreground or background or hidden.

Screenshots

No response

Desktop or Mobile Platform Information

MacOS 26.6
Desktop app Version 2.0.1 (2.0.1)

Additional Context

I did some digging: frontend.db.async/schedule-get-blocks-batch-flush! uses util/schedule (requestAnimationFrame), which might be stalling while the window is backgrounded — every <get-block call, including ones on the write path, would queue behind it indefinitely.

Suggested fix: swap util/schedule for js/setTimeout in that function. Not fully confirmed, but a local patch held up under backgrounding/sleep-wake tests that reliably stalled without it.

Are you willing to submit a PR? If you know how to fix the bug.
  • I'm willing to submit a PR (Thank you!)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/main/frontend/db/async.cljs at frontend.db.async/schedule-get-blocks-batch-flush! and inspect its use of util/schedule in src/main/frontend/util.cljc. Reproduce the write calls while the desktop window is backgrounded or after sleep-wake, then verify that writes no longer stall or arrive in a backlog when the window regains focus.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure, javascript
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.