From 02b1406f04a0f8f65f49db66762588a4646de515 Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Thu, 12 Dec 2024 15:56:33 +0100 Subject: [PATCH] feat: streaming headers (#686) --- src/unleash.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/unleash.ts b/src/unleash.ts index 7c6eaaa9..4edcd670 100644 --- a/src/unleash.ts +++ b/src/unleash.ts @@ -1,7 +1,7 @@ import { tmpdir } from 'os'; import { EventEmitter } from 'events'; import Client from './client'; -import Repository, { RepositoryInterface } from './repository'; +import Repository, { RepositoryInterface, SUPPORTED_SPEC_VERSION } from './repository'; import Metrics from './metrics'; import { Context } from './context'; import { Strategy, defaultStrategies } from './strategy'; @@ -21,6 +21,7 @@ import FileStorageProvider from './repository/storage-provider-file'; import { resolveUrl } from './url-utils'; // @ts-expect-error import { EventSource } from 'launchdarkly-eventsource'; +import { buildHeaders } from './request'; export { Strategy, UnleashEvents, UnleashConfig }; const BACKUP_PATH: string = tmpdir(); @@ -129,7 +130,14 @@ export class Unleash extends EventEmitter { eventSource: experimentalMode?.type === 'streaming' ? new EventSource(resolveUrl(unleashUrl, './client/streaming'), { - headers: customHeaders, + headers: buildHeaders( + appName, + instanceId, + undefined, + undefined, + customHeaders, + SUPPORTED_SPEC_VERSION, + ), readTimeoutMillis: 60000, // start a new SSE connection when no heartbeat received in 1 minute initialRetryDelayMillis: 2000, maxBackoffMillis: 30000,