Skip to content

When fetching flags and we run into an error and have a valid cache we should return the cached flags #93

@gazreese

Description

@gazreese

In

private func handleFlagsError(_ error: any Error, completion: @Sendable @escaping (Result<[Flag], any Error>) -> Void) {
if defaultFlags.isEmpty {
completion(.failure(error))
} else {
completion(.success(defaultFlags))
}
}
we could add some code to return the cached flags in the case of a fetch error.

I think we need to determine why we got to the point where we got the error in the first place if the cache is valid. Surely we would have already have returned the cached values?

Let's add some tests to cover the API error scenarios and ensure that either we're returning cached values anyway, or we need to fall back to the cache in handleFlagsError()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions