Skip to content

Commit 56f40cf

Browse files
authored
Merge branch 'main' into release-please--branches--main--components--launchdarkly-client-provider
Signed-off-by: Todd Baert <[email protected]>
2 parents 0ffec3a + be7851c commit 56f40cf

File tree

7 files changed

+38
-6
lines changed

7 files changed

+38
-6
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"libs/providers/env-var": "0.3.1",
77
"libs/providers/config-cat": "0.7.2",
88
"libs/providers/launchdarkly-client": "0.3.1",
9-
"libs/providers/go-feature-flag-web": "0.2.2",
9+
"libs/providers/go-feature-flag-web": "0.2.3",
1010
"libs/shared/flagd-core": "0.2.5",
1111
"libs/shared/ofrep-core": "0.2.0",
1212
"libs/providers/ofrep": "0.2.0",

libs/providers/go-feature-flag-web/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [0.2.3](https://github.com/open-feature/js-sdk-contrib/compare/go-feature-flag-web-provider-v0.2.2...go-feature-flag-web-provider-v0.2.3) (2024-12-13)
4+
5+
6+
### 🐛 Bug Fixes
7+
8+
* **go-feature-flag-web:** avoid infinite loop in waitWebsocketFinalSt… ([#1104](https://github.com/open-feature/js-sdk-contrib/issues/1104)) ([2cc7483](https://github.com/open-feature/js-sdk-contrib/commit/2cc7483ea0f8d178d5abfacfdce804db83704ba7))
9+
310
## [0.2.2](https://github.com/open-feature/js-sdk-contrib/compare/go-feature-flag-web-provider-v0.2.1...go-feature-flag-web-provider-v0.2.2) (2024-12-03)
411

512

libs/providers/go-feature-flag-web/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/providers/go-feature-flag-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openfeature/go-feature-flag-web-provider",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"scripts": {
55
"publish-if-not-exists": "cp $NPM_CONFIG_USERCONFIG .npmrc && if [ \"$(npm show $npm_package_name@$npm_package_version version)\" = \"$(npm run current-version -s)\" ]; then echo 'already published, skipping'; else npm publish --access public; fi",
66
"current-version": "echo $npm_package_version"

libs/providers/launchdarkly-client/src/lib/launchdarkly-client-provider.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ describe('LaunchDarklyClientProvider', () => {
8080
expect(initialize).toHaveBeenCalledTimes(1);
8181
/* when not set in open feauture LD sdk initialize should be called with the anonymous context*/
8282
expect(initialize).toHaveBeenCalledWith(envKey, { anonymous: true }, { logger });
83+
expect(ldClientMock.waitForInitialization).toHaveBeenCalledWith(undefined);
84+
});
85+
86+
it('should call Ld waitForInitialization with correct arguments', async () => {
87+
const provider = new LaunchDarklyClientProvider(envKey, { logger, initializationTimeout: 5 });
88+
await provider.initialize();
89+
expect(initialize).toHaveBeenCalledTimes(1);
90+
/* when not set in open feauture LD sdk initialize should be called with the anonymous context*/
91+
expect(initialize).toHaveBeenCalledWith(envKey, { anonymous: true }, { logger });
92+
expect(ldClientMock.waitForInitialization).toHaveBeenCalledTimes(1);
93+
expect(ldClientMock.waitForInitialization).toHaveBeenCalledWith(5);
8394
});
8495

8596
it('should set the status to READY if initialization succeeds', async () => {

libs/providers/launchdarkly-client/src/lib/launchdarkly-client-provider.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export class LaunchDarklyClientProvider implements Provider {
4242

4343
private readonly ldOptions: LDOptions | undefined;
4444
private readonly logger: Logger;
45+
private readonly initializationTimeout?: number;
4546
private _client?: LDClient;
4647

4748
public events = new OpenFeatureEventEmitter();
@@ -62,13 +63,14 @@ export class LaunchDarklyClientProvider implements Provider {
6263

6364
constructor(
6465
private readonly envKey: string,
65-
{ logger, ...ldOptions }: LaunchDarklyProviderOptions,
66+
{ logger, initializationTimeout, ...ldOptions }: LaunchDarklyProviderOptions,
6667
) {
6768
if (logger) {
6869
this.logger = logger;
6970
} else {
7071
this.logger = basicLogger({ level: 'info' });
7172
}
73+
this.initializationTimeout = initializationTimeout;
7274
this.ldOptions = { ...ldOptions, logger: this.logger };
7375
}
7476

@@ -92,7 +94,7 @@ export class LaunchDarklyClientProvider implements Provider {
9294
}
9395

9496
try {
95-
await this._client.waitForInitialization();
97+
await this._client.waitForInitialization(this.initializationTimeout);
9698
this.status = ProviderStatus.READY;
9799
} catch {
98100
this.status = ProviderStatus.ERROR;

libs/providers/launchdarkly-client/src/lib/launchdarkly-provider-options.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,16 @@ export interface LaunchDarklyProviderOptions extends LDOptions {
3636
* disclaimer: this logger instance will be used by the launch-darkly sdk
3737
*/
3838
logger?: LDLogger | Logger;
39+
40+
/**
41+
* Configures the amount of time, in seconds, to wait for initialization when
42+
* connecting to the LaunchDarkly service.
43+
*
44+
* Using a large timeout is not recommended as network delays may cause your
45+
* application to wait a long time before continuing execution.
46+
*
47+
* See the launchdarkly-js-client-sdk docs for more details:
48+
* {@link https://launchdarkly.github.io/js-client-sdk/interfaces/LDClient.html#waitForInitialization}
49+
*/
50+
initializationTimeout?: number;
3951
}

0 commit comments

Comments
 (0)