Skip to content

Commit e3c5cc7

Browse files
committed
chore: reverting sheddable defaults
1 parent c6a9c83 commit e3c5cc7

4 files changed

Lines changed: 24 additions & 28 deletions

File tree

packages/sdk/browser/src/BrowserClient.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ class BrowserClientImpl extends LDClientImpl {
238238
context: LDContext,
239239
identifyOptions?: LDIdentifyOptions,
240240
): Promise<LDIdentifyResult> {
241-
const res = await super.identifyResult(context, identifyOptions);
241+
const options =
242+
identifyOptions?.sheddable === undefined
243+
? { ...identifyOptions, sheddable: true }
244+
: identifyOptions;
245+
const res = await super.identifyResult(context, options);
242246
// Ensure that we do not start the goal manager if start() is not called.
243247
if (this.startPromise) {
244248
this._goalManager?.startTracking();

packages/sdk/electron/src/ElectronClient.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
LDFlagValue,
1818
LDHeaders,
1919
LDIdentifyOptions,
20+
LDIdentifyResult,
21+
LDLogger,
2022
LDPluginEnvironmentMetadata,
2123
LDWaitForInitializationOptions,
2224
LDWaitForInitializationResult,
@@ -136,6 +138,17 @@ export class ElectronClient extends LDClientImpl {
136138
internal.safeRegisterPlugins(this.logger, this.environmentMetadata, client, this._plugins);
137139
}
138140

141+
override async identifyResult(
142+
context: LDContext,
143+
identifyOptions?: LDIdentifyOptions,
144+
): Promise<LDIdentifyResult> {
145+
const options =
146+
identifyOptions?.sheddable === undefined
147+
? { ...identifyOptions, sheddable: true }
148+
: identifyOptions;
149+
return super.identifyResult(context, options);
150+
}
151+
139152
async setConnectionMode(mode: ConnectionMode): Promise<void> {
140153
if (mode === 'offline') {
141154
this.setEventSendingEnabled(false, true);

packages/shared/sdk-client/__tests__/LDClientImpl.start.test.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ describe('LDClientImpl.start()', () => {
275275
expect(result.status).toBe('completed');
276276
});
277277

278-
it('defaults sheddable to true for post-start identifies when requiresStart is true', async () => {
278+
it('allows concurrent identifies after start', async () => {
279279
const mockPlatform = setupStreamingPlatform();
280280
const { ldc } = setupClient(mockPlatform, { requiresStart: true, initialContext: context });
281281

@@ -292,21 +292,6 @@ describe('LDClientImpl.start()', () => {
292292
]);
293293

294294
expect(startResult.status).toBe('complete');
295-
expect(result1.status).toBe('shed');
296-
expect(result2.status).toBe('shed');
297-
expect(result3.status).toBe('completed');
298-
});
299-
300-
it('does not default sheddable when requiresStart is false', async () => {
301-
const mockPlatform = setupStreamingPlatform();
302-
const { ldc } = setupClient(mockPlatform, { requiresStart: false });
303-
304-
const promise1 = ldc.identifyResult({ kind: 'user', key: 'user-1' });
305-
const promise2 = ldc.identifyResult({ kind: 'user', key: 'user-2' });
306-
const promise3 = ldc.identifyResult({ kind: 'user', key: 'user-3' });
307-
308-
const [result1, result2, result3] = await Promise.all([promise1, promise2, promise3]);
309-
310295
expect(result1.status).toBe('completed');
311296
expect(result2.status).toBe('completed');
312297
expect(result3.status).toBe('completed');

packages/shared/sdk-client/src/LDClientImpl.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,8 @@ export default class LDClientImpl implements LDClient, LDClientIdentifyResult {
386386
return { status: 'error', error: new Error('Identify called before start') };
387387
}
388388

389-
let effectiveOptions = identifyOptions;
390-
if (this._requiresStart && identifyOptions?.sheddable === undefined) {
391-
effectiveOptions = { ...identifyOptions, sheddable: true };
392-
}
393-
394-
const identifyTimeout = effectiveOptions?.timeout ?? DEFAULT_IDENTIFY_TIMEOUT_SECONDS;
395-
const noTimeout =
396-
effectiveOptions?.timeout === undefined && effectiveOptions?.noTimeout === true;
389+
const identifyTimeout = identifyOptions?.timeout ?? DEFAULT_IDENTIFY_TIMEOUT_SECONDS;
390+
const noTimeout = identifyOptions?.timeout === undefined && identifyOptions?.noTimeout === true;
397391

398392
// When noTimeout is specified, and a timeout is not specified, then this condition cannot
399393
// be encountered. (Our default would need to be greater)
@@ -415,7 +409,7 @@ export default class LDClientImpl implements LDClient, LDClientIdentifyResult {
415409
}
416410
const checkedContext = Context.fromLDContext(context);
417411
if (checkedContext.valid) {
418-
const afterIdentify = this._hookRunner.identify(context, effectiveOptions?.timeout);
412+
const afterIdentify = this._hookRunner.identify(context, identifyOptions?.timeout);
419413
return {
420414
context,
421415
checkedContext,
@@ -448,7 +442,7 @@ export default class LDClientImpl implements LDClient, LDClientIdentifyResult {
448442
identifyResolve,
449443
identifyReject,
450444
checkedContext,
451-
effectiveOptions,
445+
identifyOptions,
452446
);
453447

454448
return identifyPromise;
@@ -463,7 +457,7 @@ export default class LDClientImpl implements LDClient, LDClientIdentifyResult {
463457
}
464458
},
465459
},
466-
effectiveOptions?.sheddable ?? false,
460+
identifyOptions?.sheddable ?? false,
467461
)
468462
.then((res) => {
469463
if (res.status === 'error') {

0 commit comments

Comments
 (0)