fix(store): preserve calendar-object identity on unchanged refetch#8378
Merged
SebastianKrupinski merged 1 commit intoJun 4, 2026
Merged
Conversation
SebastianKrupinski
requested changes
May 21, 2026
Contributor
Author
|
Since it is a timing issue and there were not any step-by-step instructions, it was hard for me to reproduce at first. I have added another video to issue #8367. The trick is to keep the editor open until the background synchronization is complete and only then save your changes. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Nico Donath <ndo84bw@gmx.de>
3105232 to
211044b
Compare
SebastianKrupinski
approved these changes
Jun 4, 2026
Contributor
SebastianKrupinski
left a comment
There was a problem hiding this comment.
I was finally able to reproduce the issue.
Tested the fix, it work as expected.
Contributor
|
Rebase to head and trimmed the comment a bit. |
Contributor
|
/backport to stable6.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
appendOrUpdateCalendarObjectsMutationno longer replaces an existingcalendarObjects[id]with a fresh instance when the ETag is unchanged. The existing instance is kept, so references to it (notably the open editor'scalendarObject) stay attached.Why
The editor shows stale state after save+reopen because of an object-identity detachment:
this.calendarObjectpoints to the store instancecalendarObjects[id].getEventsFromCalendarInTimeRange) runs andappendOrUpdateCalendarObjectsMutationdoescalendarObjects[id] = newInstance- even when the refetched object is byte-identical (same ETag). The store entry is now a different instance; the editor still holds the old one.updateCalendarObjectmutates and PUTs the editor's (now detached) object. The server is updated correctly, but the store entry is untouched.getEventByObjectIdreturns the store entry (the un-mutated instance) -> the editor shows the pre-save state.notify_push). The intermittency depends on whether a refetch happens to land during the open editor session.The fix skips the replacement when the ETag is unchanged (same ETag means byte-identical content, so nothing is lost), preserving instance identity. Genuinely changed objects (different ETag) are still replaced.
Alternatives considered
dav/calendarComponent/ ... onto the stored object) instead of skipping. This also preserves identity, but it would overwrite the editor's in-progress, unsaved working copy when that copy shares thecalendarComponent, and it needs field-by-field copying that is easy to get wrong. The ETag-skip avoids touching anything precisely when there is nothing new to apply.getEventByObjectId(its existing TODO: send a HEAD and compare ETags on editor open). That would address the reopen read but not the underlying instance churn, and it adds a request on every open.We chose the ETag-skip as the smallest change that fixes the observed cause without risking the editor's unsaved edits.
Tested
Root cause confirmed on the live instance (NC 33.0.3.2 / Calendar 6.4.1) via temporary instrumentation: logging every overwrite, save and reopen-read showed that stale reopens coincide exactly with the editor's
calendarObjectno longer being identical to the store entry, and that the detaching overwrite always carried the same ETag as the store entry.Fix verified live on the same instance: changing the location 20 times in a row (edit -> save -> reopen each time) showed the just-saved value every time, with no stale reopen. Reproduced clean in both the full editor and the popup editor (both go through the same
EditorMixin-> store path).Unit tests (added in this PR,
npm run test:unit):