| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Change
Sorry, something went wrong.
Co-authored-by: Espen Hovlandsdal <espen@hovlandsdal.com>
|
Thanks! I found a semi-related issue that I'm working on fixing, then I'll do a release. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What
EventSource#onEvent set each message event's lastEventId to event.id || '', i.e. the id of the current event. Whenever an event arrived without an id field, this blanked lastEventId instead of carrying the previously seen value.
Per the WHATWG spec (server-sent events, "dispatch the event"), a message event's lastEventId is initialized from the connection's last event ID buffer, which is only updated by an explicit id field and must survive events that omit it.
Fix
Emit the persisted #lastEventId buffer (coerced to '' when still unset) instead of the current event's id.
The #lastEventId buffer 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-ids test endpoint that writes one event with id: 1 then one without, and a test that records every event (the two arrive back to back, so lastArg alone would already point at the second by the time the first is asserted). The second event must still carry lastEventId: '1'.
test/client.test.ts node 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.