Skip to content

Commit 6e9d037

Browse files
authored
Merge pull request #235 from Flagsmith/fix/concurrent-identity-requests
fix: Silently handle request response miss-matches
2 parents 1a47754 + 8f9c0c8 commit 6e9d037

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

flagsmith-core.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ const Flagsmith = class {
8585
isFetching: true
8686
})
8787
}
88-
const handleResponse = ({ flags: features, traits }: IFlagsmithResponse) => {
88+
const handleResponse = (response: IFlagsmithResponse | null) => {
89+
if(!response) {
90+
return // getJSON returned null due to request/response mismatch
91+
}
92+
let { flags: features, traits }: IFlagsmithResponse = response
8993
this.isLoading = false;
9094
if (identity) {
9195
this.withTraits = null;
@@ -188,7 +192,7 @@ const Flagsmith = class {
188192
])
189193
.then((res) => {
190194
this.withTraits = null
191-
return handleResponse(res[0] as IFlagsmithResponse)
195+
return handleResponse(res?.[0] as IFlagsmithResponse | null)
192196
}).catch(({ message }) => {
193197
const error = new Error(message)
194198
return Promise.reject(error)

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": "4.0.2",
3+
"version": "4.0.3",
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": "4.0.2",
3+
"version": "4.0.3",
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": "4.0.2",
3+
"version": "4.0.3",
44
"description": "Feature flagging to support continuous development",
55
"main": "./index.js",
66
"repository": {

0 commit comments

Comments
 (0)