eventsource icon indicating copy to clipboard operation
eventsource copied to clipboard

Casing of Last-Event-ID header must be exact or duplicate events can be received after reconnect

Open cdhowie opened this issue 4 years ago • 0 comments

I am observing the following behavior with the current npm version of this library (1.1.0).

If the following sequence of events occurs:

  • EventSource is constructed with an explicit header value for Last-Event-ID but with different casing.
  • At least one event with an ID is received.

On the next successful reconnection, this library will send the initially-provided Last-Event-ID value instead of the most recent event ID. This can cause a gigantic amount of history to be replayed on the server and duplicate messages received, depending on how many messages were received since the instance was constructed.

As HTTP headers are case-insensitive, it seems wrong that the casing of the Last-Event-ID header provided to the constructor should in any way affect the observable behavior of this library.

cdhowie avatar Jul 13 '21 02:07 cdhowie