-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.0.1
-
MOODLE_400_STABLE
With the current implementation, when subsequent handler updates are triggered the initial update is reused. This is creating a race condition when the change that caused a subsequent update has not been used in the initial update.
You can look at the example below for more details, but this can potentially result in bugs whenever more than one update is triggered. In particular, application startup is very susceptible from suffering this, and this has already manifested during MOBILE-4025 where this problem was discovered.
Example:
Imagine we have a handler that uses the a fictional site property called "secret number" like this:
async isEnabled(siteId: string): Promise<boolean> {
|
const site = await CoreSites.getSite(siteId);
|
const secretNumber = await site.getSecretNumber();
|
const isValid = await this.validateSecretNumber(secretNumber);
|
|
return isValid;
|
}
|
And imagine that this validateSecretNumber method calls an external API, so it can take several seconds to resolve.
If updating this secret number triggered handler updates, and we run the following code, the end state is likely to be wrong because the handler will be updated only using the initial secret number:
site.setSecretNumber(0); // invalid number
|
|
// a short while after... (not long enough for validateSecretNumber to resolve)
|
|
site.setSecretNumber(42); // valid number!
|
- Discovered while testing
-
MOBILE-4025 Disable Dashboard, Site Home & My Courses: the first time it loads my courses
-
- Closed
-