Skip to content

[stable33] fix/autosave timer - #8989

Merged
mejo- merged 19 commits into
stable33from
backport/8928/stable33
Sep 28, 2026
Merged

mejo- merged 19 commits into
stable33from
backport/8928/stable33

Conversation

@backportbot

@backportbot backportbot Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Backport of #8928

Warning, This backport's changes differ from the original and might be incomplete 鈿狅笍

Todo

  • Review and resolve any conflicts
  • Review and verify the backported changes
  • Remove all the empty commits
  • Amend HEAD commit to remove the line stating to skip CI

Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@backportbot
backportbot Bot requested a review from mejo- August 6, 2026 05:13
@backportbot backportbot Bot added this to the Nextcloud 33.0.8 milestone Aug 6, 2026
@max-nextcloud max-nextcloud changed the title [stable33] [stable34] fix/autosave timer [stable33] fix/autosave timer Aug 6, 2026
@max-nextcloud max-nextcloud self-assigned this Aug 6, 2026
@github-project-automation github-project-automation Bot moved this to 馃Л Planning evaluation (don't pick) in 馃摑 Productivity team Aug 6, 2026
@max-nextcloud max-nextcloud moved this from 馃Л Planning evaluation (don't pick) to 馃憖 In review in 馃摑 Productivity team Aug 6, 2026
@max-nextcloud
max-nextcloud force-pushed the backport/8928/stable33 branch from a4505f1 to e011a8e Compare August 6, 2026 09:32
max-nextcloud and others added 17 commits September 28, 2026 14:53
Debounce will delay the execution of the function every time it is called.
So autosave was waiting until no updates occured for 30 seconds.

That's a long time and does not feel responsive.
Try to autosave every time the user stops typing for at least one second.

Signed-off-by: Max <max@nextcloud.com>
Also removed the document attribute from the `sync` event load.
It is already included in the `change` event load.

Signed-off-by: Max <max@nextcloud.com>
The server will only accept autosaves every 10 seconds.
`document` contains the last saved timestamp.
Compute the time to autosave next.
Add a small random delay (up to 3 seconds)
to avoid all connected clients from saving at the same time.

Signed-off-by: Max <max@nextcloud.com>
Keep track of the version that has our changes
and compare it to the last saved version on the server.

This allows fixing two scenarios:
* Server response happily to save but does not actually save.
  The server will only save new versions every 10 seconds.
  If the latest save just happened it will still respond with 200
  but list the outdated version in the response.
  Comparing the versions shows that our changes have not been saved yet.
* Other user already saved the file.
  our changes.
  So far dirty would stay true until WE save our changes.
  Comparing the versions also shows the file was saved
  when it was saved by someone else.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
* `getSaveData` now prepares the data to send to the server.
* `provideSaveService` now handles all the sync service events
  calling functions on `saveService` where needed.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
The server will only perform one actual save every 10 seconds.

Trigger another autosave if the save attempt was throttled.
`document` is udpated by throttled save attempts.
Rely on its `lastSavedVersionTime` for the retry.

Signed-off-by: Max <max@nextcloud.com>
* If the server claims to have saved the doc in the future
  use the current timestamp instead.
  Autosave happens at least ten seconds after `lastSavedVersionTime`.
  So if that was far into the future it would never happen.

* If the server is living in the past
  delay the autosave retries
  without relying on `lastSavedVersionTime`.

Signed-off-by: Max <max@nextcloud.com>
Adding a random offset makes determenistic testing harder.

Now we also do not depend on in sync clocks.

Signed-off-by: Max <max@nextcloud.com>
Autosave is triggered by the push of the steps.
Saving before that delays the autosave because of server throttling.

Signed-off-by: Max <max@nextcloud.com>
Some of our runners are slow. Give them more time to finish the runs.

Also separate local and CI config in the config file.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Only consider the local clock.
Avoid problems if clocks are out of sync
or if the server is unresponsive and `lastSavedVersionTime` does not get updated

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Allow importing with ts extensions.
This way we can backport changes to the import statements more easily.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Jonas <jonas@freesources.org>
@mejo-
mejo- force-pushed the backport/8928/stable33 branch from e011a8e to a1d5f7d Compare September 28, 2026 12:55
@mejo-
mejo- marked this pull request as ready for review September 28, 2026 13:29
We observed save requests that took longer than 30 seconds.
The lock needs to outlive those in order to prevent superfluous 409 responses.

Signed-off-by: Max <max@nextcloud.com>
Abort autosave if another save is still under way.
We observed save requests taking up to 30 seconds.
In this timespan autosave requests would still be processed
as the lastSavedTime in the database has not been updated yet.

Signed-off-by: Max <max@nextcloud.com>
@mejo-
mejo- force-pushed the backport/8928/stable33 branch from 821640b to b100aa0 Compare September 28, 2026 15:40
@mejo-
mejo- merged commit fefa8fa into stable33 Sep 28, 2026
70 checks passed
@mejo-
mejo- deleted the backport/8928/stable33 branch September 28, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 鈽戯笍 Done

Development

Successfully merging this pull request may close these issues.

4 participants