fix: preserve lastEventId when a later event omits the id field - #358
Merged
rexxars merged 4 commits intoAug 20, 2026
Merged
Conversation
rexxars
requested changes
Aug 20, 2026
Co-authored-by: Espen Hovlandsdal <espen@hovlandsdal.com>
rexxars
approved these changes
Aug 20, 2026
Member
|
Thanks! I found a semi-related issue that I'm working on fixing, then I'll do a release. |
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.
What
EventSource#onEventset each message event'slastEventIdtoevent.id || '', i.e. the id of the current event. Whenever an event arrived without anidfield, this blankedlastEventIdinstead of carrying the previously seen value.Per the WHATWG spec (server-sent events, "dispatch the event"), a message event's
lastEventIdis initialized from the connection's last event ID buffer, which is only updated by an explicitidfield and must survive events that omit it.Fix
Emit the persisted
#lastEventIdbuffer (coerced to''when still unset) instead of the current event's id.The
#lastEventIdbuffer is already updated correctly a few lines above (if (typeof event.id === 'string') this.#lastEventId = event.id), so this is a one-line behavioural fix plus a comment.Test
Adds a
/mixed-idstest endpoint that writes one event withid: 1then one without, and a test that records every event (the two arrive back to back, solastArgalone would already point at the second by the time the first is asserted). The second event must still carrylastEventId: '1'.lastEventId: ''.lastEventId: '1'for both.test/client.test.tsnode suite: 41 passed, 1 skipped (the pre-existing[NON-SPEC]case that needs a live cross-origin connection). Red re-verified against the unfixed source.