File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -424,7 +424,7 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
424424 // encode here to deal with non ASCII characters in the key
425425 const tag = `_N_T_${ key === '/index' ? '/' : encodeURI ( key ) } `
426426
427- purgeEdgeCache ( tag )
427+ requestContext ?. trackBackgroundWork ( purgeEdgeCache ( tag ) )
428428 }
429429 }
430430 } )
Original file line number Diff line number Diff line change @@ -84,23 +84,21 @@ function getCacheTagsFromTagOrTags(tagOrTags: string | string[]): string[] {
8484 . filter ( Boolean )
8585}
8686
87- export function purgeEdgeCache ( tagOrTags : string | string [ ] ) : void {
87+ export function purgeEdgeCache ( tagOrTags : string | string [ ] ) : Promise < void > {
8888 const tags = getCacheTagsFromTagOrTags ( tagOrTags )
8989
9090 if ( tags . length === 0 ) {
91- return
91+ return Promise . resolve ( )
9292 }
9393
9494 getLogger ( ) . debug ( `[NextRuntime] Purging CDN cache for: [${ tags } .join(', ')]` )
9595
96- const purgeCachePromise = purgeCache ( { tags, userAgent : purgeCacheUserAgent } ) . catch ( ( error ) => {
96+ return purgeCache ( { tags, userAgent : purgeCacheUserAgent } ) . catch ( ( error ) => {
9797 // TODO: add reporting here
9898 getLogger ( )
9999 . withError ( error )
100100 . error ( `[NextRuntime] Purging the cache for tags [${ tags . join ( ',' ) } ] failed` )
101101 } )
102-
103- getRequestContext ( ) ?. trackBackgroundWork ( purgeCachePromise )
104102}
105103
106104async function doRevalidateTagAndPurgeEdgeCache ( tags : string [ ] ) : Promise < void > {
@@ -126,7 +124,7 @@ async function doRevalidateTagAndPurgeEdgeCache(tags: string[]): Promise<void> {
126124 } ) ,
127125 )
128126
129- purgeEdgeCache ( tags )
127+ await purgeEdgeCache ( tags )
130128}
131129
132130export function markTagsAsStaleAndPurgeEdgeCache ( tagOrTags : string | string [ ] ) {
You can’t perform that action at this time.
0 commit comments