Skip to content

Commit ae5de8b

Browse files
prepare 3.2.12 release (#34)
1 parent 912bf8c commit ae5de8b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Stream.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ import { base64URLEncode, getLDHeaders, objectHasOwnProperty } from './utils';
33

44
// The underlying event source implementation is abstracted via the platform object, which should
55
// have these three properties:
6-
// eventSourceFactory(): a function that takes a URL and optional request body and returns an object
7-
// with the same methods as the regular HTML5 EventSource object. Passing a body parameter means
8-
// that the request should use REPORT instead of GET.
6+
// eventSourceFactory(): a function that takes a URL and optional config object and returns an object
7+
// with the same methods as the regular HTML5 EventSource object. The properties in the config
8+
// object are those supported by the launchdarkly-eventsource package; browser EventSource
9+
// implementations don't have any config options.
910
// eventSourceIsActive(): a function that takes an EventSource-compatible object and returns true if
1011
// it is in an active state (connected or connecting).
1112
// eventSourceAllowsReport: true if REPORT is supported.
1213

14+
// The read timeout for the stream is a fixed value that is set to be slightly longer than the expected
15+
// interval between heartbeats from the LaunchDarkly streaming server. If this amount of time elapses
16+
// with no new data, the connection will be cycled.
17+
const streamReadTimeoutMillis = 5 * 60 * 1000; // 5 minutes
18+
1319
export default function Stream(platform, config, environment, diagnosticsAccumulator) {
1420
const baseUrl = config.streamUrl;
1521
const logger = config.logger;
@@ -79,7 +85,7 @@ export default function Stream(platform, config, environment, diagnosticsAccumul
7985
reconnectTimeoutReference = null;
8086
let url;
8187
let query = '';
82-
const options = { headers };
88+
const options = { headers, readTimeoutMillis: streamReadTimeoutMillis };
8389
if (platform.eventSourceFactory) {
8490
if (hash !== null && hash !== undefined) {
8591
query = 'h=' + hash;

0 commit comments

Comments
 (0)