Skip to content

fix(sync): reset #sending flag when no active connection on sendStepsNow#8796

Open
omnizs38 wants to merge 3 commits into
nextcloud:mainfrom
omnizs38:main
Open

fix(sync): reset #sending flag when no active connection on sendStepsNow#8796
omnizs38 wants to merge 3 commits into
nextcloud:mainfrom
omnizs38:main

Conversation

@omnizs38

@omnizs38 omnizs38 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

  • Resolves:

When sendStepsNow() is called without an active connection, it sets this.#sending = true and then returns early — but never resets the flag to false.

The sendSteps() interval guards its body with !this.#sending, so once this early-return path is hit, the interval fires forever but sendStepsNow() is never called again. All locally typed changes accumulate in the outbox and are silently never pushed to the server, even after the connection recovers resulting in data loss.

Fix: reset this.#sending = false before the early return.

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI tools
  • The AI-generated content was reviewed, comprehended and tested by a human

Without this fix, a connection loss during step push setup leaves
#sending permanently true. The sendSteps() interval checks !this.#sending
before calling sendStepsNow(), so all subsequent local changes are silently
dropped — never sent to the server — even after the connection recovers.

Signed-off-by: omnizs38 <omnizs@proton.me>

@mejo- mejo- left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@omnizs38 did you run into an actual bug that you're fixing here, or was it a random finding by AI?

The fix in SyncService.ts looks sensible to me. Do you agree @max-nextcloud?

this.bus.emit('stateChange', { dirty: true })
}
if (!this.hasActiveConnection()) {
this.#sending = false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like a sensible fix to me. We return early but don't rest this.#sending.

const openResult = { connection, data: initialData }

describe('Sync service', () => {
it('resets #sending when there is no active connection', async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The test looks useless to me, I'd drop it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, but I'm not at home right now. When I am, I'll definitely make some edits based on your suggestions. Thank you very much!

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