diff --git a/packages/sdk/browser/src/BrowserClient.ts b/packages/sdk/browser/src/BrowserClient.ts index 8b8417c38..a8c2aab1d 100644 --- a/packages/sdk/browser/src/BrowserClient.ts +++ b/packages/sdk/browser/src/BrowserClient.ts @@ -141,7 +141,7 @@ export class BrowserClient extends LDClientImpl implements LDClient { return `/sdk/evalx/${clientSideId}/context`; }, pathPing(_encoding: Encoding, _plainContextString: string): string { - return `/ping/${clientSideId}`; + throw new Error('Ping for polling unsupported.'); }, }), () => ({ @@ -152,7 +152,7 @@ export class BrowserClient extends LDClientImpl implements LDClient { return `/eval/${clientSideId}`; }, pathPing(_encoding: Encoding, _plainContextString: string): string { - throw new Error('Ping for polling unsupported.'); // TODO: come back to think on this case more + return `/ping/${clientSideId}`; }, }), baseHeaders, diff --git a/packages/sdk/browser/src/BrowserDataManager.ts b/packages/sdk/browser/src/BrowserDataManager.ts index 400944abf..d97b79918 100644 --- a/packages/sdk/browser/src/BrowserDataManager.ts +++ b/packages/sdk/browser/src/BrowserDataManager.ts @@ -106,7 +106,7 @@ export default class BrowserDataManager extends BaseDataManager { this.dataSourceStatusManager.requestStateUpdate(DataSourceState.Initializing); const plainContextString = JSON.stringify(Context.toLDContext(context)); - const requestor = makeRequestor( + const pollingRequestor = makeRequestor( plainContextString, this.config.serviceEndpoints, this.getPollingPaths(), @@ -119,7 +119,7 @@ export default class BrowserDataManager extends BaseDataManager { this._secureModeHash, ); - const payload = await requestor.requestPayload(); + const payload = await pollingRequestor.requestPayload(); try { const listeners = this.createStreamListeners(context, identifyResolve); const putListener = listeners.get('put'); @@ -209,7 +209,7 @@ export default class BrowserDataManager extends BaseDataManager { this.updateProcessor?.close(); const plainContextString = JSON.stringify(Context.toLDContext(context)); - const requestor = makeRequestor( + const pollingRequestor = makeRequestor( plainContextString, this.config.serviceEndpoints, this.getPollingPaths(), // note: this is the polling path because the requestor is only used to make polling requests. @@ -222,7 +222,13 @@ export default class BrowserDataManager extends BaseDataManager { this._secureModeHash, ); - this.createStreamingProcessor(rawContext, context, requestor, identifyResolve, identifyReject); + this.createStreamingProcessor( + rawContext, + context, + pollingRequestor, + identifyResolve, + identifyReject, + ); this.updateProcessor!.start(); } diff --git a/packages/sdk/react-native/__tests__/MobileDataManager.test.ts b/packages/sdk/react-native/__tests__/MobileDataManager.test.ts index b2c80f5c7..88da353ac 100644 --- a/packages/sdk/react-native/__tests__/MobileDataManager.test.ts +++ b/packages/sdk/react-native/__tests__/MobileDataManager.test.ts @@ -133,7 +133,7 @@ describe('given a MobileDataManager with mocked dependencies', () => { return `/msdk/evalx/context`; }, pathPing(_encoding: Encoding, _plainContextString: string): string { - return `/mping`; // TODO: test this out + throw new Error('Ping for polling unsupported.'); }, }), () => ({ @@ -144,7 +144,7 @@ describe('given a MobileDataManager with mocked dependencies', () => { return `/meval`; }, pathPing(_encoding: Encoding, _plainContextString: string): string { - throw new Error('Ping for polling unsupported.'); // TODO: come back to think on this case more + return `/mping`; }, }), baseHeaders, diff --git a/packages/sdk/react-native/src/ReactNativeLDClient.ts b/packages/sdk/react-native/src/ReactNativeLDClient.ts index b980db220..1d22949bd 100644 --- a/packages/sdk/react-native/src/ReactNativeLDClient.ts +++ b/packages/sdk/react-native/src/ReactNativeLDClient.ts @@ -90,7 +90,7 @@ export default class ReactNativeLDClient extends LDClientImpl { return `/msdk/evalx/context`; }, pathPing(_encoding: Encoding, _plainContextString: string): string { - return `/mping`; // TODO: test this out + throw new Error('Ping for polling unsupported.'); }, }), () => ({ @@ -101,7 +101,7 @@ export default class ReactNativeLDClient extends LDClientImpl { return `/meval`; }, pathPing(_encoding: Encoding, _plainContextString: string): string { - throw new Error('Ping for polling unsupported.'); // TODO: come back to think on this case more + return `/mping`; }, }), baseHeaders, diff --git a/packages/shared/sdk-client/src/DataManager.ts b/packages/shared/sdk-client/src/DataManager.ts index fb2067164..14b9e866a 100644 --- a/packages/shared/sdk-client/src/DataManager.ts +++ b/packages/shared/sdk-client/src/DataManager.ts @@ -124,6 +124,7 @@ export abstract class BaseDataManager implements DataManager { this._dataSourceEventHandler.handlePollingError(err); identifyReject?.(err); }, + this.logger, ); this.updateProcessor = this._decorateProcessorWithStatusReporting( @@ -161,6 +162,7 @@ export abstract class BaseDataManager implements DataManager { this._dataSourceEventHandler.handleStreamingError(e); identifyReject?.(e); }, + this.logger, ); this.updateProcessor = this._decorateProcessorWithStatusReporting( diff --git a/packages/shared/sdk-client/src/streaming/StreamingProcessor.ts b/packages/shared/sdk-client/src/streaming/StreamingProcessor.ts index 162a6f25f..f6aad31af 100644 --- a/packages/shared/sdk-client/src/streaming/StreamingProcessor.ts +++ b/packages/shared/sdk-client/src/streaming/StreamingProcessor.ts @@ -181,7 +181,6 @@ class StreamingProcessor implements subsystem.LDStreamProcessor { // here we set up a listener that will poll when ping is received eventSource.addEventListener('ping', async () => { - this._pollingRequestor.requestPayload(); this._logger?.debug('Got PING, going to poll LaunchDarkly for feature flag updates'); try { const res = await this._pollingRequestor.requestPayload();