Skip to content

Commit c0203e7

Browse files
authored
Merge branch 'main' into feat/add_unleash_provider
2 parents a95aa2b + 929ff6d commit c0203e7

14 files changed

+181
-79
lines changed

.release-please-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"libs/providers/flagd-web": "0.7.2",
66
"libs/providers/env-var": "0.3.1",
77
"libs/providers/config-cat": "0.7.2",
8-
"libs/providers/launchdarkly-client": "0.3.0",
9-
"libs/providers/go-feature-flag-web": "0.2.2",
8+
"libs/providers/launchdarkly-client": "0.3.1",
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/go-feature-flag-web/src/lib/go-feature-flag-web-provider.spec.ts

Lines changed: 93 additions & 46 deletions
Large diffs are not rendered by default.

libs/providers/go-feature-flag-web/src/lib/go-feature-flag-web-provider.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ export class GoFeatureFlagWebProvider implements Provider {
106106
this._logger?.debug(`${GoFeatureFlagWebProvider.name}: Trying to connect the websocket at ${wsURL}`);
107107

108108
this._websocket = new WebSocket(wsURL);
109-
await this.waitWebsocketFinalStatus(this._websocket);
109+
await this.waitWebsocketFinalStatus(this._websocket).catch((reason) => {
110+
throw new Error(`impossible to connect to the websocket: ${reason}`);
111+
});
110112

111113
this._websocket.onopen = (event) => {
112114
this._logger?.info(`${GoFeatureFlagWebProvider.name}: Websocket to go-feature-flag open: ${event}`);
@@ -133,15 +135,24 @@ export class GoFeatureFlagWebProvider implements Provider {
133135
* @param socket - the websocket you are waiting for
134136
*/
135137
waitWebsocketFinalStatus(socket: WebSocket): Promise<void> {
136-
return new Promise((resolve) => {
137-
const checkConnection = () => {
138-
if (socket.readyState === WebSocket.OPEN || socket.readyState === WebSocket.CLOSED) {
139-
return resolve();
138+
return new Promise((resolve, reject) => {
139+
// wait until the socket is in a stable state or until the timeout is reached
140+
const websocketTimeout = this._apiTimeout !== 0 ? this._apiTimeout : 5000;
141+
const timeout = setTimeout(() => {
142+
if (socket.readyState !== WebSocket.OPEN && socket.readyState !== WebSocket.CLOSED) {
143+
reject(`timeout of ${websocketTimeout} ms reached when initializing the websocket`);
140144
}
141-
// Wait 5 milliseconds before checking again
142-
setTimeout(checkConnection, 5);
145+
}, websocketTimeout);
146+
147+
socket.onopen = () => {
148+
clearTimeout(timeout);
149+
resolve();
150+
};
151+
152+
socket.onclose = () => {
153+
clearTimeout(timeout);
154+
resolve();
143155
};
144-
checkConnection();
145156
});
146157
}
147158

libs/providers/launchdarkly-client/CHANGELOG.md

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

3+
## [0.3.1](https://github.com/open-feature/js-sdk-contrib/compare/launchdarkly-client-provider-v0.3.0...launchdarkly-client-provider-v0.3.1) (2024-12-17)
4+
5+
6+
### ✨ New Features
7+
8+
* Accept timeout for LD waitForInitialization ([#1117](https://github.com/open-feature/js-sdk-contrib/issues/1117)) ([be7851c](https://github.com/open-feature/js-sdk-contrib/commit/be7851ce59a772a32d60fcb3f2d23eac3c862087))
9+
10+
11+
### 🧹 Chore
12+
13+
* loosen some test assertions, fix e2e matcher ([#933](https://github.com/open-feature/js-sdk-contrib/issues/933)) ([8def607](https://github.com/open-feature/js-sdk-contrib/commit/8def6072c5d29eaf81d7262b6878cb3d6ff40483))
14+
315
## [0.3.0](https://github.com/open-feature/js-sdk-contrib/compare/launchdarkly-client-provider-v0.2.1...launchdarkly-client-provider-v0.3.0) (2024-03-25)
416

517

libs/providers/launchdarkly-client/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/launchdarkly-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openfeature/launchdarkly-client-provider",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
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 () => {

0 commit comments

Comments
 (0)