Skip to content

Commit b4a7ffe

Browse files
fix: use copy-anything for deepClone to be compatible with nodeJS before v17 (open-feature#429)
Signed-off-by: Thomas Poignant <[email protected]>
1 parent 9966281 commit b4a7ffe

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
TypeMismatchError,
1111
} from '@openfeature/js-sdk';
1212
import axios from 'axios';
13+
import {copy} from 'copy-anything';
1314
import {transformContext} from './context-transformer';
1415
import {ProxyNotReady} from './errors/proxyNotReady';
1516
import {ProxyTimeout} from './errors/proxyTimeout';
@@ -117,11 +118,11 @@ export class GoFeatureFlagProvider implements Provider {
117118
*/
118119
async callGoffDataCollection() {
119120
if (this.dataCollectorBuffer?.length === 0) {
120-
return
121+
return;
121122
}
122123

123-
const dataToSend = structuredClone(this.dataCollectorBuffer);
124-
this.dataCollectorBuffer = []
124+
const dataToSend = copy(this.dataCollectorBuffer) || [];
125+
this.dataCollectorBuffer = [];
125126

126127
const request: DataCollectorRequest<boolean> = {events: dataToSend, meta: this.dataCollectorMetadata,}
127128
const endpointURL = new URL(this.endpoint);
@@ -138,7 +139,7 @@ export class GoFeatureFlagProvider implements Provider {
138139
} catch (e) {
139140
this.logger?.error(`impossible to send the data to the collector: ${e}`)
140141
// if we have an issue calling the collector we put the data back in the buffer
141-
this.dataCollectorBuffer = [...this.dataCollectorBuffer, ...dataToSend]
142+
this.dataCollectorBuffer = [...this.dataCollectorBuffer, ...dataToSend];
142143
}
143144
}
144145

package-lock.json

+39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@swc/helpers": "~0.5.0",
2323
"axios": "1.4.0",
2424
"configcat-js": "^8.0.0",
25+
"copy-anything": "^3.0.5",
2526
"launchdarkly-js-client-sdk": "^3.1.3",
2627
"lodash.isequal": "^4.5.0",
2728
"lru-cache": "^10.0.0",

0 commit comments

Comments
 (0)