File tree 2 files changed +5
-7
lines changed
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 {
424
424
// encode here to deal with non ASCII characters in the key
425
425
const tag = `_N_T_${ key === '/index' ? '/' : encodeURI ( key ) } `
426
426
427
- purgeEdgeCache ( tag )
427
+ requestContext ?. trackBackgroundWork ( purgeEdgeCache ( tag ) )
428
428
}
429
429
}
430
430
} )
Original file line number Diff line number Diff line change @@ -84,23 +84,21 @@ function getCacheTagsFromTagOrTags(tagOrTags: string | string[]): string[] {
84
84
. filter ( Boolean )
85
85
}
86
86
87
- export function purgeEdgeCache ( tagOrTags : string | string [ ] ) : void {
87
+ export function purgeEdgeCache ( tagOrTags : string | string [ ] ) : Promise < void > {
88
88
const tags = getCacheTagsFromTagOrTags ( tagOrTags )
89
89
90
90
if ( tags . length === 0 ) {
91
- return
91
+ return Promise . resolve ( )
92
92
}
93
93
94
94
getLogger ( ) . debug ( `[NextRuntime] Purging CDN cache for: [${ tags } .join(', ')]` )
95
95
96
- const purgeCachePromise = purgeCache ( { tags, userAgent : purgeCacheUserAgent } ) . catch ( ( error ) => {
96
+ return purgeCache ( { tags, userAgent : purgeCacheUserAgent } ) . catch ( ( error ) => {
97
97
// TODO: add reporting here
98
98
getLogger ( )
99
99
. withError ( error )
100
100
. error ( `[NextRuntime] Purging the cache for tags [${ tags . join ( ',' ) } ] failed` )
101
101
} )
102
-
103
- getRequestContext ( ) ?. trackBackgroundWork ( purgeCachePromise )
104
102
}
105
103
106
104
async function doRevalidateTagAndPurgeEdgeCache ( tags : string [ ] ) : Promise < void > {
@@ -126,7 +124,7 @@ async function doRevalidateTagAndPurgeEdgeCache(tags: string[]): Promise<void> {
126
124
} ) ,
127
125
)
128
126
129
- purgeEdgeCache ( tags )
127
+ await purgeEdgeCache ( tags )
130
128
}
131
129
132
130
export function markTagsAsStaleAndPurgeEdgeCache ( tagOrTags : string | string [ ] ) {
You can’t perform that action at this time.
0 commit comments