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)?
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
📝 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)