Skip to content

Race condition between cache check and loadIfNeeded() #237

@pcantrell

Description

@pcantrell

When instantiating a Resource, Siesta checks for cached data asynchronously, updating the resource later if there is a cache hit (and if the resource hasn’t loaded fresh data in the meantime). This is good, but it creates a race condition where loadIfNeeded may initiate a network request if called before the cache check is done.

Instead, loadIfNeeded() should return a chained request that first waits for the cache check if there is one in progress, and only chains to the a network request if the we got a cache miss.

(Original SO question)

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