diff --git a/package-lock.json b/package-lock.json index b4b92aa56c..d6e4396a86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@netlify/edge-bundler": "^12.2.3", "@netlify/edge-functions": "^2.11.0", "@netlify/eslint-config-node": "^7.0.1", - "@netlify/functions": "^2.8.2", + "@netlify/functions": "^3.0.0", "@netlify/serverless-functions-api": "^1.30.1", "@netlify/zip-it-and-ship-it": "^9.41.0", "@opentelemetry/api": "^1.8.0", @@ -4780,15 +4780,15 @@ } }, "node_modules/@netlify/functions": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-2.8.2.tgz", - "integrity": "sha512-DeoAQh8LuNPvBE4qsKlezjKj0PyXDryOFJfJKo3Z1qZLKzQ21sT314KQKPVjfvw6knqijj+IO+0kHXy/TJiqNA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-3.0.0.tgz", + "integrity": "sha512-XXf9mNw4+fkxUzukDpJtzc32bl1+YlXZwEhc5ZgMcTbJPLpgRLDs5WWSPJ4eY/Mv1ZFvtxmMwmfgoQYVt68Qog==", "dev": true, "dependencies": { - "@netlify/serverless-functions-api": "1.26.1" + "@netlify/serverless-functions-api": "1.30.1" }, "engines": { - "node": ">=14.0.0" + "node": ">=18.0.0" } }, "node_modules/@netlify/functions-utils": { @@ -4805,19 +4805,6 @@ "node": "^14.16.0 || >=16.0.0" } }, - "node_modules/@netlify/functions/node_modules/@netlify/serverless-functions-api": { - "version": "1.26.1", - "resolved": "https://registry.npmjs.org/@netlify/serverless-functions-api/-/serverless-functions-api-1.26.1.tgz", - "integrity": "sha512-q3L9i3HoNfz0SGpTIS4zTcKBbRkxzCRpd169eyiTuk3IwcPC3/85mzLHranlKo2b+HYT0gu37YxGB45aD8A3Tw==", - "dev": true, - "dependencies": { - "@netlify/node-cookies": "^0.1.0", - "urlpattern-polyfill": "8.0.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@netlify/git-utils": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/@netlify/git-utils/-/git-utils-5.1.1.tgz", @@ -39465,24 +39452,12 @@ } }, "@netlify/functions": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-2.8.2.tgz", - "integrity": "sha512-DeoAQh8LuNPvBE4qsKlezjKj0PyXDryOFJfJKo3Z1qZLKzQ21sT314KQKPVjfvw6knqijj+IO+0kHXy/TJiqNA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-3.0.0.tgz", + "integrity": "sha512-XXf9mNw4+fkxUzukDpJtzc32bl1+YlXZwEhc5ZgMcTbJPLpgRLDs5WWSPJ4eY/Mv1ZFvtxmMwmfgoQYVt68Qog==", "dev": true, "requires": { - "@netlify/serverless-functions-api": "1.26.1" - }, - "dependencies": { - "@netlify/serverless-functions-api": { - "version": "1.26.1", - "resolved": "https://registry.npmjs.org/@netlify/serverless-functions-api/-/serverless-functions-api-1.26.1.tgz", - "integrity": "sha512-q3L9i3HoNfz0SGpTIS4zTcKBbRkxzCRpd169eyiTuk3IwcPC3/85mzLHranlKo2b+HYT0gu37YxGB45aD8A3Tw==", - "dev": true, - "requires": { - "@netlify/node-cookies": "^0.1.0", - "urlpattern-polyfill": "8.0.2" - } - } + "@netlify/serverless-functions-api": "1.30.1" } }, "@netlify/functions-utils": { diff --git a/package.json b/package.json index caff8bf295..5c78f70bd2 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@netlify/edge-bundler": "^12.2.3", "@netlify/edge-functions": "^2.11.0", "@netlify/eslint-config-node": "^7.0.1", - "@netlify/functions": "^2.8.2", + "@netlify/functions": "^3.0.0", "@netlify/serverless-functions-api": "^1.30.1", "@netlify/zip-it-and-ship-it": "^9.41.0", "@opentelemetry/api": "^1.8.0", diff --git a/src/run/handlers/cache.cts b/src/run/handlers/cache.cts index 69dcd4271c..2ec5cb4bb3 100644 --- a/src/run/handlers/cache.cts +++ b/src/run/handlers/cache.cts @@ -11,6 +11,7 @@ import { type Span } from '@opentelemetry/api' import type { PrerenderManifest } from 'next/dist/build/index.js' import { NEXT_CACHE_TAGS_HEADER } from 'next/dist/lib/constants.js' +import { name as nextRuntimePkgName, version as nextRuntimePkgVersion } from '../../../package.json' import { type CacheHandlerContext, type CacheHandlerForMultipleVersions, @@ -30,6 +31,8 @@ type TagManifest = { revalidatedAt: number } type TagManifestBlobCache = Record> +const purgeCacheUserAgent = `${nextRuntimePkgName}@${nextRuntimePkgVersion}` + export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions { options: CacheHandlerContext revalidatedTags: string[] @@ -347,12 +350,14 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions { const tag = `_N_T_${key === '/index' ? '/' : encodeURI(key)}` getLogger().debug(`Purging CDN cache for: [${tag}]`) requestContext.trackBackgroundWork( - purgeCache({ tags: tag.split(/,|%2c/gi) }).catch((error) => { - // TODO: add reporting here - getLogger() - .withError(error) - .error(`[NetlifyCacheHandler]: Purging the cache for tag ${tag} failed`) - }), + purgeCache({ tags: tag.split(/,|%2c/gi), userAgent: purgeCacheUserAgent }).catch( + (error) => { + // TODO: add reporting here + getLogger() + .withError(error) + .error(`[NetlifyCacheHandler]: Purging the cache for tag ${tag} failed`) + }, + ), ) } } @@ -393,7 +398,7 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions { }), ) - await purgeCache({ tags }).catch((error) => { + await purgeCache({ tags, userAgent: purgeCacheUserAgent }).catch((error) => { // TODO: add reporting here getLogger() .withError(error)