Skip to content

Commit d7b3458

Browse files
committed
fix: make revalidateTags no-op when list of tags is empty
1 parent 4d7ad97 commit d7b3458

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/run/handlers/cache.cts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,12 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
345345
if (requestContext?.didPagesRouterOnDemandRevalidate) {
346346
// encode here to deal with non ASCII characters in the key
347347
const tag = `_N_T_${key === '/index' ? '/' : encodeURI(key)}`
348+
const tags = tag.split(/,|%2c/gi)
349+
350+
if (tags.length === 0) {
351+
return
352+
}
353+
348354
getLogger().debug(`Purging CDN cache for: [${tag}]`)
349355
requestContext.trackBackgroundWork(
350356
purgeCache({ tags: tag.split(/,|%2c/gi) }).catch((error) => {
@@ -379,6 +385,10 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
379385
tag.split(/,|%2c/gi),
380386
)
381387

388+
if (tags.length === 0) {
389+
return
390+
}
391+
382392
const data: TagManifest = {
383393
revalidatedAt: Date.now(),
384394
}

0 commit comments

Comments
 (0)