Skip to content

Commit a9299b1

Browse files
committed
MOBILE-2915 site: Fix clearing of cached request promises
1 parent 78ec165 commit a9299b1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/classes/site.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ export class CoreSite {
582582
});
583583
}
584584

585-
let promise = this.getFromCache(method, data, preSets, false, originalData).catch(() => {
585+
const promise = this.getFromCache(method, data, preSets, false, originalData).catch(() => {
586586
// Do not pass those options to the core WS factory.
587587
return this.wsProvider.call(method, data, wsPreSets).then((response) => {
588588
if (preSets.saveToCache) {
@@ -690,14 +690,12 @@ export class CoreSite {
690690
this.ongoingRequests[cacheId] = promise;
691691

692692
// Clear ongoing request after setting the promise (just in case it's already resolved).
693-
promise = promise.finally(() => {
693+
return promise.finally(() => {
694694
// Make sure we don't clear the promise of a newer request that ignores the cache.
695695
if (this.ongoingRequests[cacheId] === promise) {
696696
delete this.ongoingRequests[cacheId];
697697
}
698-
});
699-
700-
return promise.then((response) => {
698+
}).then((response) => {
701699
// We pass back a clone of the original object, this may prevent errors if in the callback the object is modified.
702700
return this.utils.clone(response);
703701
});

0 commit comments

Comments
 (0)