Skip to content

Commit dae9268

Browse files
committed
fix: prevent duplicate parses
1 parent a208567 commit dae9268

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/runtime/server/storage.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ export const getContent = async (event: H3Event, id: string): Promise<ParsedCont
160160
return cached.parsed as ParsedContent
161161
}
162162

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

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

176176
resolve(parsed)
177177

178-
delete pendingPromises[hash]
178+
delete pendingPromises[id + hash]
179179
})
180180
}
181181

182-
return pendingPromises[hash]
182+
return pendingPromises[id + hash]
183183
}
184184

185185
/**

0 commit comments

Comments
 (0)