Skip to content

Commit

Permalink
Merge pull request #235 from Flagsmith/fix/concurrent-identity-requests
Browse files Browse the repository at this point in the history
fix: Silently handle request response miss-matches
  • Loading branch information
kyle-ssg authored Jul 3, 2024
2 parents 1a47754 + 8f9c0c8 commit 6e9d037
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions flagsmith-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ const Flagsmith = class {
isFetching: true
})
}
const handleResponse = ({ flags: features, traits }: IFlagsmithResponse) => {
const handleResponse = (response: IFlagsmithResponse | null) => {
if(!response) {
return // getJSON returned null due to request/response mismatch
}
let { flags: features, traits }: IFlagsmithResponse = response
this.isLoading = false;
if (identity) {
this.withTraits = null;
Expand Down Expand Up @@ -188,7 +192,7 @@ const Flagsmith = class {
])
.then((res) => {
this.withTraits = null
return handleResponse(res[0] as IFlagsmithResponse)
return handleResponse(res?.[0] as IFlagsmithResponse | null)
}).catch(({ message }) => {
const error = new Error(message)
return Promise.reject(error)
Expand Down
2 changes: 1 addition & 1 deletion lib/flagsmith-es/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flagsmith-es",
"version": "4.0.2",
"version": "4.0.3",
"description": "Feature flagging to support continuous development. This is an esm equivalent of the standard flagsmith npm module.",
"main": "./index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion lib/flagsmith/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flagsmith",
"version": "4.0.2",
"version": "4.0.3",
"description": "Feature flagging to support continuous development",
"main": "./index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion lib/react-native-flagsmith/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-flagsmith",
"version": "4.0.2",
"version": "4.0.3",
"description": "Feature flagging to support continuous development",
"main": "./index.js",
"repository": {
Expand Down

0 comments on commit 6e9d037

Please sign in to comment.