data-provider/core

Selectors never resolving data when dependencies cleanCache method is called frequently

Closed this issue · 0 comments

Description

When dependencies of a Selector are taking some time to load, and the cache of one of them is cleaned with more frequency than the time that all dependencies take to be resolved, then the Selector never resolves the data, it remains "loading" forever.

For example, if dependencies A,B,C are declared in sequency and each one take 2 second to be resolved, the Selector should be resolved in 6 seconds. But, if you execute cleanCache on the the A dependency each 4 seconds (as in a theorical polling scenario), then the Selector never resolves.

Cause:

Selectors are waiting for the new data of a dependency when its cleanCache method is called. They actively listen to the cleanCache method of all of its dependencies. If any of them cleans the cache, then it stops reading dependencies and start again in order to have the latest data available.

Possible solution:

A restartReadOnCleanedDependenciesMaxTime option could be added to the selectors, so, when it reaches this max time, it will not stop reading the rest of dependencies. It could have a default value of 5 seconds, as this is a very unusual scenario.