Skip to content

Commit 02b1406

Browse files
authored
feat: streaming headers (#686)
1 parent a735a2b commit 02b1406

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/unleash.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { tmpdir } from 'os';
22
import { EventEmitter } from 'events';
33
import Client from './client';
4-
import Repository, { RepositoryInterface } from './repository';
4+
import Repository, { RepositoryInterface, SUPPORTED_SPEC_VERSION } from './repository';
55
import Metrics from './metrics';
66
import { Context } from './context';
77
import { Strategy, defaultStrategies } from './strategy';
@@ -21,6 +21,7 @@ import FileStorageProvider from './repository/storage-provider-file';
2121
import { resolveUrl } from './url-utils';
2222
// @ts-expect-error
2323
import { EventSource } from 'launchdarkly-eventsource';
24+
import { buildHeaders } from './request';
2425
export { Strategy, UnleashEvents, UnleashConfig };
2526

2627
const BACKUP_PATH: string = tmpdir();
@@ -129,7 +130,14 @@ export class Unleash extends EventEmitter {
129130
eventSource:
130131
experimentalMode?.type === 'streaming'
131132
? new EventSource(resolveUrl(unleashUrl, './client/streaming'), {
132-
headers: customHeaders,
133+
headers: buildHeaders(
134+
appName,
135+
instanceId,
136+
undefined,
137+
undefined,
138+
customHeaders,
139+
SUPPORTED_SPEC_VERSION,
140+
),
133141
readTimeoutMillis: 60000, // start a new SSE connection when no heartbeat received in 1 minute
134142
initialRetryDelayMillis: 2000,
135143
maxBackoffMillis: 30000,

0 commit comments

Comments
 (0)