Skip to content

[stable35] fix(indexedDB): close the database when the editor closes - #9632

Open
backportbot[bot] wants to merge 7 commits into
stable35from
backport/9630/stable35
Open

backportbot[bot] wants to merge 7 commits into
stable35from
backport/9630/stable35

Conversation

@backportbot

@backportbot backportbot Bot commented Nov 18, 2026

Copy link
Copy Markdown

Backport of PR #9630

A typo set `hasConnectionIssues` instead of `hasConnectionIssue`. After a
connection issue, a push rejected with 403 kept showing "The document
could not be loaded" instead of "You've been disconnected from the
server".

With the flag cleared, the connection issue watcher made the editor
editable again 200 ms later, although the rejected session had switched
it to read-only. The watcher now only re-enables editing in edit mode.
This also keeps documents that were opened read-only from becoming
editable after a connection issue.

A sync answered after the rejection could set the connection issue flag
again and bring back the old message. The status card now shows the
disconnected state first.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Every opened document left its IndexedDB connection and awareness
interval open after the editor was closed. Navigating between pages
piled up dangling connections and timers.

Destroy the ydoc in `close()`. Its destroy event closes the IndexedDB
connection and stops the awareness interval. Skip reading from the
database once the ydoc is destroyed.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
…cting

When coming back online, the sync response retried the push while the
save was still pushing the same steps. The server stored them twice, so
the save only covered the first copy. The autosave scheduled for the
second one was then cancelled when the save finished, leaving the
document at "Unsaved changes".

- SyncService: sendStepsNow joins a push in flight instead of sending
  the outbox again. sendRemainingSteps waits for it and pushes any steps
  that remain, so saving and closing still send everything.
- SaveService: clear the pending autosave before emitting the save
  event, and only when the save succeeded.
- useSaveService: after a save, schedule an autosave if newer changes
  were pushed in the meantime.

Fixes the flaky autosave e2e test "saves after being disconnected for
2 minutes".

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Destroying the sync provider on close sends a last awareness step after
the connection was already cleared. It started the 200 ms send interval,
which only stopped after a push, so every closed editor left an interval
running that kept the sync service reachable. The interval now stops
once there is no connection; the next step after reconnecting starts a
new one.

The beforeunload listener stayed registered if the editor was closed
with unsaved changes, because only the dirty watcher removed it and
watchers no longer run after unmounting.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
…stener

Yjs sets `Doc.isDestroyed` before it emits `destroy`, so the composable
no longer tracks the destroyed ydoc in its own flag. The local flag now
only records that the data was cleared, which also closes the database
while the ydoc stays alive.

The early return in `whenSynced` could not run: y-indexeddb never emits
`synced` once it is destroyed, so `whenSynced` does not settle for a
ydoc destroyed before the initial load.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
Saving pushes the local changes first. If the server rejects that push,
the session is invalidated and the connection cleared, but the save went
ahead with it and failed with "Cannot read properties of undefined
(reading 'shareToken')". Check the connection after pushing instead.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
The status cards for connection issues, a rejected session or a
conflict are added and removed as the state changes and use
role="note", so screen readers did not announce them. The always
rendered status wrapper is now a polite live region.

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
@backportbot backportbot Bot added bug Something isn't working 3. to review feature: offline support AI assisted This PR contains AI-assisted commits labels Nov 18, 2026
@backportbot backportbot Bot added this to the Nextcloud 35.0.4 milestone Nov 18, 2026
@backportbot backportbot Bot added bug Something isn't working 3. to review feature: offline support AI assisted This PR contains AI-assisted commits labels Nov 18, 2026
@mejo-
mejo- enabled auto-merge November 18, 2026 15:14
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/composables/useSaveService.ts 83.33% 1 Missing ⚠️
src/services/SyncService.ts 90.90% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review AI assisted This PR contains AI-assisted commits bug Something isn't working feature: offline support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant