Skip to content

Commit b018621

Browse files
authored
Merge pull request #205 from Flagsmith/chore/compare-requested-and-current-identity
Check requested/current identity when receiving a response
2 parents 943f512 + 79af5e6 commit b018621

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

flagsmith-core.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,14 @@ const Flagsmith = class {
9696
console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");
9797
}
9898

99+
const requestedIdentity = `${this.identity}`
99100
return _fetch(url, options)
100101
.then(res => {
102+
const newIdentity = `${this.identity}`;
103+
if(requestedIdentity!==newIdentity){
104+
this.log(`Received response with identity miss-match, ignoring response. Requested: ${requestedIdentity}, Current: ${newIdentity}`)
105+
return
106+
}
101107
const lastUpdated = res.headers?.get('x-flagsmith-document-updated-at');
102108
if(lastUpdated) {
103109
try {
@@ -380,7 +386,7 @@ const Flagsmith = class {
380386
onError(message)
381387
} else {
382388
onError(new Error(message))
383-
}
389+
}
384390
}
385391
}
386392

@@ -652,7 +658,7 @@ const Flagsmith = class {
652658
error = WRONG_FLAGSMITH_CONFIG
653659
}
654660
this.onChange?.(null, { isFromServer: false, flagsChanged: true, traitsChanged:!!this.traits },this._loadedState(error, FlagSource.DEFAULT_FLAGS));
655-
661+
656662
}
657663
resolve(true);
658664
}

lib/flagsmith-es/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flagsmith-es",
3-
"version": "3.21.1",
3+
"version": "3.22.0",
44
"description": "Feature flagging to support continuous development. This is an esm equivalent of the standard flagsmith npm module.",
55
"main": "./index.js",
66
"type": "module",

lib/flagsmith/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flagsmith",
3-
"version": "3.21.1",
3+
"version": "3.22.0",
44
"description": "Feature flagging to support continuous development",
55
"main": "./index.js",
66
"repository": {

lib/react-native-flagsmith/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-flagsmith",
3-
"version": "3.21.1",
3+
"version": "3.22.0",
44
"description": "Feature flagging to support continuous development",
55
"main": "./index.js",
66
"repository": {

0 commit comments

Comments
 (0)