Skip to content

Commit

Permalink
Releasing version 1.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
LaunchDarklyReleaseBot committed Jan 10, 2022
1 parent 9715f5d commit 9ed8723
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this package will be documented in this file.

## [1.4.3] - 2022-01-10
This release fixes a number of SSE spec compliance issues which do not affect usage in the LaunchDarkly SDKs, but could be relevant in other use cases.

### Fixed:
- If an event's `id:` field contains a null character, the whole field should be ignored.
- The parser was incorrectly ignoring lines that did not contain a colon, instead of treating them as a field with an empty value. For instance, `data` on a line by itself should be equivalent to `data:`.
- The parser should ignore any incomplete messages at the end of a stream if the stream disconnects.

## [1.4.2] - 2022-01-04
### Fixed:
- If the stream URL contained user/password basicauth fields, they were not being included in the request.
Expand Down
17 changes: 13 additions & 4 deletions example/eventsource-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -6557,8 +6557,7 @@ function EventSource (url, eventSourceInitDict) {
}

var discardTrailingNewline = false
var data = ''
var eventName = ''
var data, eventName, eventId

var reconnectUrl = null
var retryDelayStrategy = new retryDelay.RetryDelayStrategy(
Expand Down Expand Up @@ -6707,6 +6706,10 @@ function EventSource (url, eventSourceInitDict) {
return
}

data = ''
eventName = ''
eventId = undefined

readyState = EventSource.OPEN
res.on('close', function () {
res.removeAllListeners('close')
Expand Down Expand Up @@ -6836,16 +6839,20 @@ function EventSource (url, eventSourceInitDict) {
if (lineLength === 0) {
if (data.length > 0) {
var type = eventName || 'message'
if (eventId !== undefined) {
lastEventId = eventId
}
var event = new MessageEvent(type, {
data: data.slice(0, -1), // remove trailing newline
lastEventId: lastEventId,
origin: original(url)
})
data = ''
eventId = undefined
receivedEvent(event)
}
eventName = void 0
} else if (fieldLength > 0) {
} else {
var noValue = fieldLength < 0
var step = 0
var field = buf.slice(pos, pos + (noValue ? lineLength : fieldLength)).toString()
Expand All @@ -6867,7 +6874,9 @@ function EventSource (url, eventSourceInitDict) {
} else if (field === 'event') {
eventName = value
} else if (field === 'id') {
lastEventId = value
if (!value.includes("\u0000")) {
eventId = value
}
} else if (field === 'retry') {
var retry = parseInt(value, 10)
if (!Number.isNaN(retry)) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "launchdarkly-eventsource",
"version": "1.4.2",
"version": "1.4.3",
"description": "Fork of eventsource package - W3C compliant EventSource client for Node.js and browser (polyfill)",
"keywords": [
"eventsource",
Expand Down

0 comments on commit 9ed8723

Please sign in to comment.