Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow waiting for the network response on identify. #548

Merged
merged 5 commits into from
Aug 19, 2024

Conversation

kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Aug 16, 2024

Fixes: #503
Fixes: #505

When non-cached values are desired after identify the waitForNetworkResults identify option can be used. This will caused the identify to wait for configuration from the configured data source or timeout.

The recommended approach, for resilience and performance, will be to use cached flag values and respond to fresh values reactively and that will remain the default.

@@ -1,12 +1,9 @@
import type { Hasher } from '@common';

// eslint-disable-next-line import/no-mutable-exports
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove this piece of global data in the test updates.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was redundant.

@@ -16,6 +16,10 @@ export const setupMockStreamingProcessor = (
errorTimeoutSeconds: number = 0,
initTimeoutMs: number = 0,
) => {
let initTimeoutHandle: any;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simulated stream needs to be able to cancel its timers or it will run after tests are expected to end.

describe('sdk-client object', () => {
let ldc: LDClientImpl;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decreasing the scope of these to the fixture.

@kinyoklion kinyoklion marked this pull request as ready for review August 19, 2024 16:00
@kinyoklion kinyoklion requested a review from a team as a code owner August 19, 2024 16:00
} else {
this.logger.debug('Offline identify no storage. Defaults will be used.');
this.logger.debug(
'Offline identify - no cached flags, using defaults or already loaded flags.',
Copy link
Contributor

@tanderson-ld tanderson-ld Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestion for clarity. I had to think a bit to realize what this was conveying.

Suggested change
'Offline identify - no cached flags, using defaults or already loaded flags.',
'Identify - Currently offline with no cached flags for provided context. Maintaining current flags. This may result in default flag evaluations if no flags have been loaded before.'

Is the trailing comma intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our linting requires training coma for parameters that are not on one line. The linter also forces this line to be wrapped as such.

@kinyoklion kinyoklion merged commit 1375660 into main Aug 19, 2024
20 checks passed
@kinyoklion kinyoklion deleted the rlamb/sc-253340/identify-wait-for-network branch August 19, 2024 21:06
@github-actions github-actions bot mentioned this pull request Aug 19, 2024
kinyoklion pushed a commit that referenced this pull request Aug 19, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>js-client-sdk-common: 1.5.0</summary>

##
[1.5.0](js-client-sdk-common-v1.4.0...js-client-sdk-common-v1.5.0)
(2024-08-19)


### Features

* Allow waiting for the network response on identify.
([#548](#548))
([1375660](1375660))
</details>

<details><summary>react-native-client-sdk: 10.5.1</summary>

##
[10.5.1](react-native-client-sdk-v10.5.0...react-native-client-sdk-v10.5.1)
(2024-08-19)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @launchdarkly/js-client-sdk-common bumped from 1.4.0 to 1.5.0
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@@ -8,4 +8,16 @@ export interface LDIdentifyOptions {
* Defaults to 5 seconds.
*/
timeout: number;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kinyoklion timeout should be optional then

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately timeout was already implemented as non-optional. That said it defaults to 5, so setting it to 5 is equal to not providing it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will consider it.

There are advantages to having it non-optional and some SDKs require it with every call identify. Which makes it more obvious that the operation can timeout. We document it, but people are still often surprised that it times out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetches incorrect flag value during app init Caching on React native
3 participants