Skip to content

Commit

Permalink
fix: Don't delete existing flags on decide errors (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkakkar authored May 10, 2023
1 parent 6257540 commit 9774731
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/__tests__/featureflags.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,14 @@ describe('parseFeatureFlagDecideResponse', () => {
$enabled_feature_flags: { 'beta-feature': true, 'alpha-feature-2': true },
})
})

it('doesnt remove existing feature flags when no flags are returned', () => {
given('decideResponse', () => ({ status: 0 }))
given.subject()

expect(given.persistence.register).not.toHaveBeenCalled()
expect(given.persistence.unregister).not.toHaveBeenCalled()
})
})

describe('filterActiveFeatureFlags', () => {
Expand Down
6 changes: 0 additions & 6 deletions src/posthog-featureflags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ export const parseFeatureFlagDecideResponse = (
[PERSISTENCE_FEATURE_FLAG_PAYLOADS]: newFeatureFlagPayloads || {},
})
}
} else {
if (persistence) {
persistence.unregister(PERSISTENCE_ACTIVE_FEATURE_FLAGS)
persistence.unregister(ENABLED_FEATURE_FLAGS)
persistence.unregister(PERSISTENCE_FEATURE_FLAG_PAYLOADS)
}
}
}

Expand Down

0 comments on commit 9774731

Please sign in to comment.