diff --git a/packages/spacecat-shared-utils/src/adobe-fetch.js b/packages/spacecat-shared-utils/src/adobe-fetch.js index 5b90b601e..d13c33b02 100644 --- a/packages/spacecat-shared-utils/src/adobe-fetch.js +++ b/packages/spacecat-shared-utils/src/adobe-fetch.js @@ -11,4 +11,7 @@ */ import { context as h2, h1 } from '@adobe/fetch'; -export const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1 ? h1() : h2(); +const fetchContext = process.env.HELIX_FETCH_FORCE_HTTP1 ? h1() : h2(); +export const { + fetch, reset: resetFetchContext, clearCache: clearFetchCache, +} = fetchContext; diff --git a/packages/spacecat-shared-utils/src/index.js b/packages/spacecat-shared-utils/src/index.js index 64c623ec4..60b59ed51 100644 --- a/packages/spacecat-shared-utils/src/index.js +++ b/packages/spacecat-shared-utils/src/index.js @@ -83,7 +83,7 @@ export { s3Wrapper, getObjectFromKey } from './s3.js'; export { OPPORTUNITY_TYPES, DEFAULT_CPC_VALUE } from './constants.js'; -export { fetch } from './adobe-fetch.js'; +export { fetch, resetFetchContext, clearFetchCache } from './adobe-fetch.js'; export { tracingFetch, SPACECAT_USER_AGENT } from './tracing-fetch.js'; export { getHighFormViewsLowConversionMetrics, diff --git a/packages/spacecat-shared-utils/test/index.test.js b/packages/spacecat-shared-utils/test/index.test.js index c6a590d60..70cec92f0 100644 --- a/packages/spacecat-shared-utils/test/index.test.js +++ b/packages/spacecat-shared-utils/test/index.test.js @@ -41,6 +41,7 @@ describe('Index Exports', () => { 'ensureHttps', 'extractUrlsFromOpportunity', 'extractUrlsFromSuggestion', + 'clearFetchCache', 'fetch', 'formatAllowlistMessage', 'FORMS_AUDIT_INTERVAL', @@ -97,6 +98,7 @@ describe('Index Exports', () => { 'prettifyLogForwardingConfig', 'replacePlaceholders', 'resolveCanonicalUrl', + 'resetFetchContext', 'resolveCustomerSecretsName', 'resolveSecretsName', 's3Wrapper',