Skip to content

Commit 62ea699

Browse files
authored
fix: support revalidating multiple tags at once (#464)
1 parent 68f8e79 commit 62ea699

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/run/handlers/cache.cts

+18-9
Original file line numberDiff line numberDiff line change
@@ -208,22 +208,31 @@ export class NetlifyCacheHandler implements CacheHandler {
208208
}
209209

210210
// eslint-disable-next-line @typescript-eslint/no-explicit-any
211-
async revalidateTag(tag: string, ...args: any) {
212-
console.debug('NetlifyCacheHandler.revalidateTag', tag, args)
211+
async revalidateTag(tagOrTags: string | string[], ...args: any) {
212+
console.debug('NetlifyCacheHandler.revalidateTag', tagOrTags, args)
213+
214+
const tags = Array.isArray(tagOrTags) ? tagOrTags : [tagOrTags]
213215

214216
const data: TagManifest = {
215217
revalidatedAt: Date.now(),
216218
}
217219

218-
try {
219-
await this.blobStore.setJSON(await this.encodeBlobKey(tag), data)
220-
} catch (error) {
221-
console.warn(`Failed to update tag manifest for ${tag}`, error)
222-
}
220+
await Promise.all(
221+
tags.map(async (tag) => {
222+
try {
223+
await this.blobStore.setJSON(await this.encodeBlobKey(tag), data)
224+
} catch (error) {
225+
console.warn(`Failed to update tag manifest for ${tag}`, error)
226+
}
227+
}),
228+
)
223229

224-
purgeCache({ tags: [tag] }).catch((error) => {
230+
purgeCache({ tags }).catch((error) => {
225231
// TODO: add reporting here
226-
console.error(`[NetlifyCacheHandler]: Purging the cache for tag ${tag} failed`, error)
232+
console.error(
233+
`[NetlifyCacheHandler]: Purging the cache for tags ${tags.join(', ')} failed`,
234+
error,
235+
)
227236
})
228237
}
229238

0 commit comments

Comments
 (0)