Skip to content

Commit

Permalink
Explicit async
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Dec 19, 2024
1 parent 4623ebb commit 459f9ba
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/AssetCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class AssetCache {
return fs.readFileSync(contentPath, type !== "buffer" ? "utf8" : null);
}

getCachedContents(type) {
async getCachedContents(type) {
if(!this.#rawContents[type]) {
this.#rawContents[type] = this.#getCachedContents(type);
}
Expand Down
2 changes: 1 addition & 1 deletion src/RemoteAssetCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class RemoteAssetCache extends AssetCache {

// async but not explicitly declared for promise equality checks
// returns a Promise
fetch(optionsOverride = {}) {
async fetch(optionsOverride = {}) {
if(!this.#fetchPromise) {
// one at a time. clear when finished
this.#fetchPromise = this.#fetch(optionsOverride).finally(() => {
Expand Down
6 changes: 2 additions & 4 deletions test/QueueTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,9 @@ test("Raw Fetch using fetch method (check parallel fetch promise reuse)", async
// Make sure the instance is the same
t.is(ac1, ac2);

let fetch1 = ac1.fetch();
let fetch2 = ac1.fetch();
t.is(fetch1, fetch2);
let [result1, result2] = await Promise.all([ac1.fetch(), ac1.fetch()]);

t.is(await fetch1, await fetch2);
t.is(result1, result2);

t.false(ac1.wasLastFetchCacheHit())

Expand Down

0 comments on commit 459f9ba

Please sign in to comment.