fix(sync): reset #sending flag when no active connection on sendStepsNow#8796
fix(sync): reset #sending flag when no active connection on sendStepsNow#8796omnizs38 wants to merge 3 commits into
Conversation
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-
left a comment
There was a problem hiding this comment.
@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 |
There was a problem hiding this comment.
This looks like a sensible fix to me. We return early but don't reset this.#sending.
| const openResult = { connection, data: initialData } | ||
|
|
||
| describe('Sync service', () => { | ||
| it('resets #sending when there is no active connection', async () => { |
There was a problem hiding this comment.
The test looks useless to me, I'd drop it.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
@omnizs38 can you simply drop the test altogether from the PR?
Also, out of curiosity:
Did you run into an actual bug that you're fixing here, or was it a random finding (by AI)?
📝 Summary
When
sendStepsNow()is called without an active connection, it setsthis.#sending = trueand then returns early — but never resets the flag tofalse.The
sendSteps()interval guards its body with!this.#sending, so once this early-return path is hit, the interval fires forever butsendStepsNow()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 = falsebefore the early return.🏁 Checklist
npm run lint/npm run stylelint/composer run cs:check)🤖 AI (if applicable)