From f1963a719812202374854922fd1eb29235338fdf Mon Sep 17 00:00:00 2001 From: LaunchDarklyCI Date: Tue, 30 Jun 2020 00:48:01 +0000 Subject: [PATCH] Releasing version 1.3.1 --- CHANGELOG.md | 4 ++++ example/eventsource-polyfill.js | 11 +++++++++-- package.json | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fa81fe..1180812 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this package will be documented in this file. +## [1.3.1] - 2020-06-29 +### Fixed: +- Incorporated [a fix](https://github.com/EventSource/eventsource/pull/130) from the upstream repository that avoids unnecessary delays when parsing a long message that is received in multiple chunks. + ## [1.3.0] - 2020-04-23 ### Added: - A Node.js `http.Agent` can be specified using the `agent` option. diff --git a/example/eventsource-polyfill.js b/example/eventsource-polyfill.js index 0d55aa2..5d5d1bb 100644 --- a/example/eventsource-polyfill.js +++ b/example/eventsource-polyfill.js @@ -6666,6 +6666,8 @@ function EventSource (url, eventSourceInitDict) { // Source/WebCore/page/EventSource.cpp var isFirst = true var buf + var startingPos = 0 + var startingFieldLength = -1 res.on('data', function (chunk) { buf = buf ? Buffer.concat([buf, chunk]) : chunk if (isFirst && hasBom(buf)) { @@ -6685,10 +6687,10 @@ function EventSource (url, eventSourceInitDict) { } var lineLength = -1 - var fieldLength = -1 + var fieldLength = startingFieldLength var c - for (var i = pos; lineLength < 0 && i < length; ++i) { + for (var i = startingPos; lineLength < 0 && i < length; ++i) { c = buf[i] if (c === colon) { if (fieldLength < 0) { @@ -6703,7 +6705,12 @@ function EventSource (url, eventSourceInitDict) { } if (lineLength < 0) { + startingPos = length - pos + startingFieldLength = fieldLength break + } else { + startingPos = 0 + startingFieldLength = -1 } parseEventStreamLine(buf, pos, fieldLength, lineLength) diff --git a/package.json b/package.json index 65a61db..91a42c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "launchdarkly-eventsource", - "version": "1.3.0", + "version": "1.3.1", "description": "Fork of eventsource package - W3C compliant EventSource client for Node.js and browser (polyfill)", "keywords": [ "eventsource",