fix: ignore already known entries in polling responses - #959
Open
lstamellos wants to merge 4 commits into
Open
Conversation
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
Prevent cached polling buckets from re-queuing entries the client already knows about.
The polling start timestamp is intentionally rounded to the refresh-interval bucket for cache efficiency. This can make the requested timestamp range overlap the newest entry already known to the client, and the backend can legitimately return that entry again as
type: "new".When new entries are not auto-rendered, that duplicate can enter the pending polling state and produce a false
1 new entry availablenag.Root cause
The start-timestamp bucketing introduced in
99da1326assumes duplicate polling entries are harmless because entry updates are deduplicated by ID.That is true when applying entries to the rendered API state, but the pending polling queue is separate. A
type: "new"entry already known to the client can therefore be queued again.For example, with a 10-second refresh interval:
17863677751786367770type: "new"There is also a pagination variant of the same issue: on pages after page 1,
api.entriescontains only the currently rendered page, while the polling baseline still tracks the global newest entry. Deduplicating only against rendered IDs is therefore not sufficient.Fix
Filter polling response entries before dispatching
POLLING_SUCCESS.For
type: "new"entries, the filter:updateanddeleteentries are always preserved. Their JSONididentifies the entry being replaced rather than the newly created backing comment, so applying the same ID-based baseline rule to those entry types would be unsafe.The existing timestamp bucketing and cache behavior remain unchanged.
Tests
Adds unit coverage for:
newentriesupdateanddeleteentries for existing IDsValidation
The issue was reproduced consistently on a production WordPress liveblog using the current polling implementation.
Before the fix, the first polling cycle could show
1 new entry availablewithout any new publication.After applying equivalent deduplication logic: