Skip to content

Commit d4821a9

Browse files
authored
Caching 20230221 (#390)
* prevent cache modification when parallel fetches are waiting on the same resource * package updates
1 parent 0fd5359 commit d4821a9

File tree

2 files changed

+124
-122
lines changed

2 files changed

+124
-122
lines changed

lib/FetchEnvs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module.exports = class FetchEnvs {
8989
// When updating a key, updating it for all users
9090
for( const cacheUser of globalResourceCacheUsers ) {
9191
if( globalResourceCache.has(`${cacheUser}/${cacheKey}`) ) {
92-
globalResourceCache.set(`${cacheUser}/${cacheKey}`, resource);
92+
globalResourceCache.set(`${cacheUser}/${cacheKey}`, clone(resource));
9393
updated = true;
9494
}
9595
}
@@ -162,7 +162,7 @@ module.exports = class FetchEnvs {
162162
}
163163

164164
// Wait for the outstanding api call to complete, use it's value
165-
resource = await singleResourceQueryCache[cacheKey];
165+
resource = clone( await singleResourceQueryCache[cacheKey] );
166166
}
167167

168168
return resource;

0 commit comments

Comments
 (0)