Skip to content

Commit

Permalink
fix: prevent duplicate parses
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Oct 27, 2023
1 parent a208567 commit dae9268
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/runtime/server/storage.ts
Expand Up @@ -160,9 +160,9 @@ export const getContent = async (event: H3Event, id: string): Promise<ParsedCont
return cached.parsed as ParsedContent
}

if (!pendingPromises[hash]) {
if (!pendingPromises[id + hash]) {
// eslint-disable-next-line no-async-promise-executor
pendingPromises[hash] = new Promise(async (resolve) => {
pendingPromises[id + hash] = new Promise(async (resolve) => {
const body = await sourceStorage.getItem(id)

if (body === null) {
Expand All @@ -175,11 +175,11 @@ export const getContent = async (event: H3Event, id: string): Promise<ParsedCont

resolve(parsed)

delete pendingPromises[hash]
delete pendingPromises[id + hash]
})
}

return pendingPromises[hash]
return pendingPromises[id + hash]
}

/**
Expand Down

0 comments on commit dae9268

Please sign in to comment.