Skip to content

Commit

Permalink
fixing issues discovered during bench testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tanderson-ld committed Oct 11, 2024
1 parent 46c972e commit d1e962a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/sdk/browser/src/BrowserClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
},
}),
() => ({
Expand All @@ -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,
Expand Down
14 changes: 10 additions & 4 deletions packages/sdk/browser/src/BrowserDataManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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');
Expand Down Expand Up @@ -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.
Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/react-native/__tests__/MobileDataManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
},
}),
() => ({
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/react-native/src/ReactNativeLDClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
},
}),
() => ({
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/sdk-client/src/DataManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export abstract class BaseDataManager implements DataManager {
this._dataSourceEventHandler.handlePollingError(err);
identifyReject?.(err);
},
this.logger,
);

this.updateProcessor = this._decorateProcessorWithStatusReporting(
Expand Down Expand Up @@ -161,6 +162,7 @@ export abstract class BaseDataManager implements DataManager {
this._dataSourceEventHandler.handleStreamingError(e);
identifyReject?.(e);
},
this.logger,
);

this.updateProcessor = this._decorateProcessorWithStatusReporting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit d1e962a

Please sign in to comment.