From c65844d614f2f05fe66e0b9c26478ba78302ddfb Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 14 Oct 2024 21:00:54 +0200 Subject: [PATCH 1/9] followup http-cache --- lib/handler/cache-handler.js | 48 ++++++++++++++++++++++-------------- lib/util/cache.js | 21 ++++++++++++++++ types/cache-interceptor.d.ts | 4 ++- 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/lib/handler/cache-handler.js b/lib/handler/cache-handler.js index 2eaf0fa2417..52432026832 100644 --- a/lib/handler/cache-handler.js +++ b/lib/handler/cache-handler.js @@ -2,24 +2,32 @@ const util = require('../core/util') const DecoratorHandler = require('../handler/decorator-handler') -const { parseCacheControlHeader, parseVaryHeader, UNSAFE_METHODS, assertCacheStoreType } = require('../util/cache') +const { + assertCacheStoreType, + parseCacheControlHeader, + parseVaryHeader, + UNSAFE_METHODS +} = require('../util/cache') /** * Writes a response to a CacheStore and then passes it on to the next handler */ class CacheHandler extends DecoratorHandler { /** - * @type {import('../../types/cache-interceptor.d.ts').default.CacheOptions | null} - */ - #opts = null + * @type {import('../../types/cache-interceptor.d.ts').default.CacheStore} + */ + #store + /** - * @type {import('../../types/dispatcher.d.ts').default.RequestOptions | null} + * @type {import('../../types/dispatcher.d.ts').default.RequestOptions} */ - #req = null + #requestOptions + /** - * @type {import('../../types/dispatcher.d.ts').default.DispatchHandlers | null} + * @type {import('../../types/dispatcher.d.ts').default.DispatchHandlers} */ - #handler = null + #handler + /** * @type {import('../../types/cache-interceptor.d.ts').default.CacheStoreWriteable | undefined} */ @@ -27,19 +35,21 @@ class CacheHandler extends DecoratorHandler { /** * @param {import('../../types/cache-interceptor.d.ts').default.CacheOptions} opts - * @param {import('../../types/dispatcher.d.ts').default.RequestOptions} req + * @param {import('../../types/dispatcher.d.ts').default.RequestOptions} requestOptions * @param {import('../../types/dispatcher.d.ts').default.DispatchHandlers} handler */ - constructor (opts, req, handler) { + constructor (opts, requestOptions, handler) { super(handler) if (typeof opts !== 'object') { throw new TypeError(`expected opts to be an object, got type ${typeof opts}`) } - assertCacheStoreType(opts.store) + const { store } = opts + + assertCacheStoreType(store) - if (typeof req !== 'object') { + if (typeof requestOptions !== 'object') { throw new TypeError(`expected req to be an object, got type ${typeof opts}`) } @@ -47,8 +57,8 @@ class CacheHandler extends DecoratorHandler { throw new TypeError(`expected handler to be an object, got type ${typeof opts}`) } - this.#opts = opts - this.#req = req + this.#store = store + this.#requestOptions = requestOptions this.#handler = handler } @@ -75,14 +85,14 @@ class CacheHandler extends DecoratorHandler { ) if ( - UNSAFE_METHODS.includes(this.#req.method) && + UNSAFE_METHODS.includes(this.#requestOptions.method) && statusCode >= 200 && statusCode <= 399 ) { // https://www.rfc-editor.org/rfc/rfc9111.html#name-invalidating-stored-respons // Try/catch for if it's synchronous try { - const result = this.#opts.store.deleteByOrigin(this.#req.origin) + const result = this.#store.deleteByOrigin(this.#requestOptions.origin) if ( result && typeof result.catch === 'function' && @@ -103,7 +113,7 @@ class CacheHandler extends DecoratorHandler { const cacheControlHeader = headers['cache-control'] const contentLengthHeader = headers['content-length'] - if (!cacheControlHeader || !contentLengthHeader || this.#opts.store.isFull) { + if (!cacheControlHeader || !contentLengthHeader || this.#store.isFull) { // Don't have the headers we need, can't cache return downstreamOnHeaders() } @@ -122,7 +132,7 @@ class CacheHandler extends DecoratorHandler { const staleAt = determineStaleAt(now, headers, cacheControlDirectives) if (staleAt) { const varyDirectives = headers.vary - ? parseVaryHeader(headers.vary, this.#req.headers) + ? parseVaryHeader(headers.vary, this.#requestOptions.headers) : undefined const deleteAt = determineDeleteAt(now, cacheControlDirectives, staleAt) @@ -132,7 +142,7 @@ class CacheHandler extends DecoratorHandler { cacheControlDirectives ) - this.#writeStream = this.#opts.store.createWriteStream(this.#req, { + this.#writeStream = this.#store.createWriteStream(this.#requestOptions, { statusCode, statusMessage, rawHeaders: strippedHeaders, diff --git a/lib/util/cache.js b/lib/util/cache.js index 17ba5a31dae..66facc67057 100644 --- a/lib/util/cache.js +++ b/lib/util/cache.js @@ -1,5 +1,9 @@ 'use strict' +const SAFE_METHODS = /** @type {const} */ ([ + 'GET', 'HEAD', 'OPTIONS', 'TRACE' +]) + const UNSAFE_METHODS = /** @type {const} */ ([ 'POST', 'PUT', 'PATCH', 'DELETE' ]) @@ -196,10 +200,27 @@ function assertCacheStoreType (store) { throw new TypeError(`CacheStore needs a isFull getter with type boolean, current type: ${typeof store.isFull}`) } } +/** + * @param {unknown} methods + * @returns {asserts methods is import('../../types/cache-interceptor.d.ts').default.CacheMethods[]} + */ +function assertCacheMethods (methods) { + if (!Array.isArray(methods)) { + throw new TypeError(`expected type to be an array, got ${typeof methods}`) + } + + for (const method of methods) { + if (!UNSAFE_METHODS.includes(method)) { + throw new TypeError(`CacheMethods needs to be one of ${UNSAFE_METHODS.join(', ')}, got ${method}`) + } + } +} module.exports = { + SAFE_METHODS, UNSAFE_METHODS, parseCacheControlHeader, parseVaryHeader, + assertCacheMethods, assertCacheStoreType } diff --git a/types/cache-interceptor.d.ts b/types/cache-interceptor.d.ts index 45af1a8a5f5..7fa1aeab0ed 100644 --- a/types/cache-interceptor.d.ts +++ b/types/cache-interceptor.d.ts @@ -4,6 +4,8 @@ import Dispatcher from './dispatcher' export default CacheHandler declare namespace CacheHandler { + export type CacheMethods = 'GET' | 'HEAD' | 'OPTIONS' | 'TRACE' + export interface CacheOptions { store?: CacheStore @@ -14,7 +16,7 @@ declare namespace CacheHandler { * @see https://www.rfc-editor.org/rfc/rfc9111.html#name-invalidating-stored-respons * @see https://www.rfc-editor.org/rfc/rfc9110#section-9.2.1 */ - methods?: ('GET' | 'HEAD' | 'OPTIONS' | 'TRACE')[] + methods?: CacheMethods[] } /** From 10755d36590fad8e36262ae0117f639c97773db9 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 14 Oct 2024 21:25:22 +0200 Subject: [PATCH 2/9] fix methods check --- lib/interceptor/cache.js | 40 +++++++++++++--------------------------- lib/util/cache.js | 4 ++-- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/lib/interceptor/cache.js b/lib/interceptor/cache.js index e726ec2ba47..1213ab94666 100644 --- a/lib/interceptor/cache.js +++ b/lib/interceptor/cache.js @@ -4,39 +4,25 @@ const util = require('../core/util') const CacheHandler = require('../handler/cache-handler') const MemoryCacheStore = require('../cache/memory-cache-store') const CacheRevalidationHandler = require('../handler/cache-revalidation-handler') -const { UNSAFE_METHODS, assertCacheStoreType } = require('../util/cache.js') +const { assertCacheStoreType, assertCacheMethods } = require('../util/cache.js') const AGE_HEADER = Buffer.from('age') /** - * @param {import('../../types/cache-interceptor.d.ts').default.CacheOptions | undefined} globalOpts + * @param {import('../../types/cache-interceptor.d.ts').default.CacheOptions} [globalOpts] * @returns {import('../../types/dispatcher.d.ts').default.DispatcherComposeInterceptor} */ -module.exports = globalOpts => { - if (!globalOpts) { - globalOpts = {} - } - - if (globalOpts.store) { - assertCacheStoreType(globalOpts.store) - } else { - globalOpts.store = new MemoryCacheStore() - } +module.exports = (globalOpts = {}) => { + const { + store = new MemoryCacheStore(), + methods = ['GET'] + } = globalOpts - if (globalOpts.methods) { - if (!Array.isArray(globalOpts.methods)) { - throw new TypeError(`methods needs to be an array, got ${typeof globalOpts.methods}`) - } - - if (globalOpts.methods.length === 0) { - throw new Error('methods must have at least one method in it') - } - } else { - globalOpts.methods = ['GET'] - } + assertCacheStoreType(store) + assertCacheMethods(methods) - // Safe methods the user wants and unsafe methods - const methods = [...globalOpts.methods, ...UNSAFE_METHODS] + globalOpts.store = store + globalOpts.methods = methods return dispatch => { return (opts, handler) => { @@ -45,7 +31,7 @@ module.exports = globalOpts => { return dispatch(opts, handler) } - const stream = globalOpts.store.createReadStream(opts) + const stream = store.createReadStream(opts) if (!stream) { // Request isn't cached return dispatch(opts, new CacheHandler(globalOpts, opts, handler)) @@ -169,7 +155,7 @@ module.exports = globalOpts => { respondWithCachedValue(stream, value) } - Promise.resolve(stream).then(handleStream).catch(err => handler.onError(err)) + Promise.resolve(stream).then(handleStream).catch(handler.onError) return true } diff --git a/lib/util/cache.js b/lib/util/cache.js index 66facc67057..9fc8a9da3a0 100644 --- a/lib/util/cache.js +++ b/lib/util/cache.js @@ -210,8 +210,8 @@ function assertCacheMethods (methods) { } for (const method of methods) { - if (!UNSAFE_METHODS.includes(method)) { - throw new TypeError(`CacheMethods needs to be one of ${UNSAFE_METHODS.join(', ')}, got ${method}`) + if (!SAFE_METHODS.includes(method)) { + throw new TypeError(`CacheMethods needs to be one of ${SAFE_METHODS.join(', ')}, got ${method}`) } } } From 9a8b0b4f1d06c04aeb1ea5de6139fdccdf2ab807 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 14 Oct 2024 21:51:50 +0200 Subject: [PATCH 3/9] avoid instantiation in case of error --- lib/handler/cache-revalidation-handler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/handler/cache-revalidation-handler.js b/lib/handler/cache-revalidation-handler.js index d5293cdb166..53c58773022 100644 --- a/lib/handler/cache-revalidation-handler.js +++ b/lib/handler/cache-revalidation-handler.js @@ -32,12 +32,12 @@ class CacheRevalidationHandler extends DecoratorHandler { * @param {import('../../types/dispatcher.d.ts').default.DispatchHandlers} handler */ constructor (successCallback, handler) { - super(handler) - if (typeof successCallback !== 'function') { throw new TypeError('successCallback must be a function') } + super(handler) + this.#successCallback = successCallback this.#handler = handler } From bc5cfe79ecf4dfa638a538686d85d27c2c9cb9a9 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 14 Oct 2024 22:03:22 +0200 Subject: [PATCH 4/9] improve --- lib/core/util.js | 2 +- lib/handler/cache-handler.js | 23 +++++++++++++++-------- lib/util/cache.js | 16 +++++----------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/core/util.js b/lib/core/util.js index c37f213349b..fb311a7d36b 100644 --- a/lib/core/util.js +++ b/lib/core/util.js @@ -924,6 +924,6 @@ module.exports = { isHttpOrHttpsPrefixed, nodeMajor, nodeMinor, - safeHTTPMethods: ['GET', 'HEAD', 'OPTIONS', 'TRACE'], + safeHTTPMethods: Object.freeze(['GET', 'HEAD', 'OPTIONS', 'TRACE']), wrapRequestBody } diff --git a/lib/handler/cache-handler.js b/lib/handler/cache-handler.js index 52432026832..89aeb656a1c 100644 --- a/lib/handler/cache-handler.js +++ b/lib/handler/cache-handler.js @@ -6,7 +6,7 @@ const { assertCacheStoreType, parseCacheControlHeader, parseVaryHeader, - UNSAFE_METHODS + assertCacheMethods } = require('../util/cache') /** @@ -18,6 +18,11 @@ class CacheHandler extends DecoratorHandler { */ #store + /** + * @type {import('../../types/cache-interceptor.d.ts').default.CacheMethods} + */ + #methods + /** * @type {import('../../types/dispatcher.d.ts').default.RequestOptions} */ @@ -39,16 +44,10 @@ class CacheHandler extends DecoratorHandler { * @param {import('../../types/dispatcher.d.ts').default.DispatchHandlers} handler */ constructor (opts, requestOptions, handler) { - super(handler) - if (typeof opts !== 'object') { throw new TypeError(`expected opts to be an object, got type ${typeof opts}`) } - const { store } = opts - - assertCacheStoreType(store) - if (typeof requestOptions !== 'object') { throw new TypeError(`expected req to be an object, got type ${typeof opts}`) } @@ -57,9 +56,17 @@ class CacheHandler extends DecoratorHandler { throw new TypeError(`expected handler to be an object, got type ${typeof opts}`) } + const { store, methods = util.safeHTTPMethods } = opts + + assertCacheStoreType(store) + assertCacheMethods(methods) + + super(handler) + this.#store = store this.#requestOptions = requestOptions this.#handler = handler + this.#methods = methods } /** @@ -85,7 +92,7 @@ class CacheHandler extends DecoratorHandler { ) if ( - UNSAFE_METHODS.includes(this.#requestOptions.method) && + !this.#methods.includes(this.#requestOptions.method) && statusCode >= 200 && statusCode <= 399 ) { diff --git a/lib/util/cache.js b/lib/util/cache.js index 9fc8a9da3a0..2ae59602614 100644 --- a/lib/util/cache.js +++ b/lib/util/cache.js @@ -1,12 +1,8 @@ 'use strict' -const SAFE_METHODS = /** @type {const} */ ([ - 'GET', 'HEAD', 'OPTIONS', 'TRACE' -]) - -const UNSAFE_METHODS = /** @type {const} */ ([ - 'POST', 'PUT', 'PATCH', 'DELETE' -]) +const { + safeHTTPMethods +} = require('../core/util') /** * @see https://www.rfc-editor.org/rfc/rfc9111.html#name-cache-control @@ -210,15 +206,13 @@ function assertCacheMethods (methods) { } for (const method of methods) { - if (!SAFE_METHODS.includes(method)) { - throw new TypeError(`CacheMethods needs to be one of ${SAFE_METHODS.join(', ')}, got ${method}`) + if (!safeHTTPMethods.includes(method)) { + throw new TypeError(`CacheMethods needs to be one of ${safeHTTPMethods.join(', ')}, got ${method}`) } } } module.exports = { - SAFE_METHODS, - UNSAFE_METHODS, parseCacheControlHeader, parseVaryHeader, assertCacheMethods, From 310c2e5e2fdb40bc81d4eaac2016d884a7bce5c2 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 14 Oct 2024 22:04:59 +0200 Subject: [PATCH 5/9] rename assertCacheStoreType to assertCacheStore --- lib/handler/cache-handler.js | 8 ++++---- lib/interceptor/cache.js | 4 ++-- lib/util/cache.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/handler/cache-handler.js b/lib/handler/cache-handler.js index 89aeb656a1c..41021e73e1d 100644 --- a/lib/handler/cache-handler.js +++ b/lib/handler/cache-handler.js @@ -3,10 +3,10 @@ const util = require('../core/util') const DecoratorHandler = require('../handler/decorator-handler') const { - assertCacheStoreType, + assertCacheMethods, + assertCacheStore, parseCacheControlHeader, - parseVaryHeader, - assertCacheMethods + parseVaryHeader } = require('../util/cache') /** @@ -58,7 +58,7 @@ class CacheHandler extends DecoratorHandler { const { store, methods = util.safeHTTPMethods } = opts - assertCacheStoreType(store) + assertCacheStore(store) assertCacheMethods(methods) super(handler) diff --git a/lib/interceptor/cache.js b/lib/interceptor/cache.js index 1213ab94666..c7de4ea862f 100644 --- a/lib/interceptor/cache.js +++ b/lib/interceptor/cache.js @@ -4,7 +4,7 @@ const util = require('../core/util') const CacheHandler = require('../handler/cache-handler') const MemoryCacheStore = require('../cache/memory-cache-store') const CacheRevalidationHandler = require('../handler/cache-revalidation-handler') -const { assertCacheStoreType, assertCacheMethods } = require('../util/cache.js') +const { assertCacheStore, assertCacheMethods } = require('../util/cache.js') const AGE_HEADER = Buffer.from('age') @@ -18,7 +18,7 @@ module.exports = (globalOpts = {}) => { methods = ['GET'] } = globalOpts - assertCacheStoreType(store) + assertCacheStore(store) assertCacheMethods(methods) globalOpts.store = store diff --git a/lib/util/cache.js b/lib/util/cache.js index 2ae59602614..41aaa8de4d2 100644 --- a/lib/util/cache.js +++ b/lib/util/cache.js @@ -181,7 +181,7 @@ function parseVaryHeader (varyHeader, headers) { * @param {unknown} store * @returns {asserts store is import('../../types/cache-interceptor.d.ts').default.CacheStore} */ -function assertCacheStoreType (store) { +function assertCacheStore (store) { if (typeof store !== 'object' || store === null) { throw new TypeError(`expected type to be an store, got ${typeof store}`) } @@ -216,5 +216,5 @@ module.exports = { parseCacheControlHeader, parseVaryHeader, assertCacheMethods, - assertCacheStoreType + assertCacheStore } From a5fd83269c1e8c8b983a4695253474b758d036b5 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 14 Oct 2024 22:14:43 +0200 Subject: [PATCH 6/9] remove validation --- lib/handler/cache-handler.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/handler/cache-handler.js b/lib/handler/cache-handler.js index 41021e73e1d..11053f8038c 100644 --- a/lib/handler/cache-handler.js +++ b/lib/handler/cache-handler.js @@ -3,8 +3,6 @@ const util = require('../core/util') const DecoratorHandler = require('../handler/decorator-handler') const { - assertCacheMethods, - assertCacheStore, parseCacheControlHeader, parseVaryHeader } = require('../util/cache') @@ -44,23 +42,8 @@ class CacheHandler extends DecoratorHandler { * @param {import('../../types/dispatcher.d.ts').default.DispatchHandlers} handler */ constructor (opts, requestOptions, handler) { - if (typeof opts !== 'object') { - throw new TypeError(`expected opts to be an object, got type ${typeof opts}`) - } - - if (typeof requestOptions !== 'object') { - throw new TypeError(`expected req to be an object, got type ${typeof opts}`) - } - - if (typeof handler !== 'object') { - throw new TypeError(`expected handler to be an object, got type ${typeof opts}`) - } - const { store, methods = util.safeHTTPMethods } = opts - assertCacheStore(store) - assertCacheMethods(methods) - super(handler) this.#store = store From 85727cfa848da06fe116c0ab8ee4b51e07f470b2 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 14 Oct 2024 22:17:11 +0200 Subject: [PATCH 7/9] remove fallback --- lib/handler/cache-handler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/handler/cache-handler.js b/lib/handler/cache-handler.js index 11053f8038c..3c4044a653e 100644 --- a/lib/handler/cache-handler.js +++ b/lib/handler/cache-handler.js @@ -42,7 +42,7 @@ class CacheHandler extends DecoratorHandler { * @param {import('../../types/dispatcher.d.ts').default.DispatchHandlers} handler */ constructor (opts, requestOptions, handler) { - const { store, methods = util.safeHTTPMethods } = opts + const { store, methods } = opts super(handler) From bff7c4281b871eed6282b582458a7192a4cf1ff1 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 14 Oct 2024 22:44:55 +0200 Subject: [PATCH 8/9] fix --- lib/interceptor/cache.js | 20 +++++++++++++------- lib/util/cache.js | 18 +++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/lib/interceptor/cache.js b/lib/interceptor/cache.js index c7de4ea862f..666a87ef3e5 100644 --- a/lib/interceptor/cache.js +++ b/lib/interceptor/cache.js @@ -9,20 +9,26 @@ const { assertCacheStore, assertCacheMethods } = require('../util/cache.js') const AGE_HEADER = Buffer.from('age') /** - * @param {import('../../types/cache-interceptor.d.ts').default.CacheOptions} [globalOpts] + * @param {import('../../types/cache-interceptor.d.ts').default.CacheOptions} [opts] * @returns {import('../../types/dispatcher.d.ts').default.DispatcherComposeInterceptor} */ -module.exports = (globalOpts = {}) => { +module.exports = (opts = {}) => { const { store = new MemoryCacheStore(), methods = ['GET'] - } = globalOpts + } = opts - assertCacheStore(store) - assertCacheMethods(methods) + if (typeof opts !== 'object' || opts === null) { + throw new TypeError(`expected type of opts to be an Object, got ${store === null ? 'null' : typeof store}`) + } + + assertCacheStore(store, 'opts.store') + assertCacheMethods(methods, 'opts.methods') - globalOpts.store = store - globalOpts.methods = methods + const globalOpts = { + store, + methods + } return dispatch => { return (opts, handler) => { diff --git a/lib/util/cache.js b/lib/util/cache.js index 41aaa8de4d2..48a91da3e74 100644 --- a/lib/util/cache.js +++ b/lib/util/cache.js @@ -181,33 +181,37 @@ function parseVaryHeader (varyHeader, headers) { * @param {unknown} store * @returns {asserts store is import('../../types/cache-interceptor.d.ts').default.CacheStore} */ -function assertCacheStore (store) { +function assertCacheStore (store, name = 'CacheStore') { if (typeof store !== 'object' || store === null) { - throw new TypeError(`expected type to be an store, got ${typeof store}`) + throw new TypeError(`expected type of ${name} to be a CacheStore, got ${store === null ? 'null' : typeof store}`) } for (const fn of ['createReadStream', 'createWriteStream', 'deleteByOrigin']) { if (typeof store[fn] !== 'function') { - throw new TypeError(`CacheStore needs a \`${fn}()\` function`) + throw new TypeError(`${name} needs to have a \`${fn}()\` function`) } } if (typeof store.isFull !== 'boolean') { - throw new TypeError(`CacheStore needs a isFull getter with type boolean, current type: ${typeof store.isFull}`) + throw new TypeError(`${name} needs a isFull getter with type boolean, current type: ${typeof store.isFull}`) } } /** * @param {unknown} methods * @returns {asserts methods is import('../../types/cache-interceptor.d.ts').default.CacheMethods[]} */ -function assertCacheMethods (methods) { +function assertCacheMethods (methods, name = 'CacheMethods') { if (!Array.isArray(methods)) { - throw new TypeError(`expected type to be an array, got ${typeof methods}`) + throw new TypeError(`expected type of ${name} needs to be an array, got ${methods === null ? 'null' : typeof methods}`) + } + + if (methods.length === 0) { + throw new TypeError(`${name} needs to have at least one method`) } for (const method of methods) { if (!safeHTTPMethods.includes(method)) { - throw new TypeError(`CacheMethods needs to be one of ${safeHTTPMethods.join(', ')}, got ${method}`) + throw new TypeError(`element of ${name}-array needs to be one of following values: ${safeHTTPMethods.join(', ')}, got ${method}`) } } } From 6a099bb7ad52c7d967b3174f40d1d9ac63d7120d Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 14 Oct 2024 22:46:16 +0200 Subject: [PATCH 9/9] fix --- lib/interceptor/cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/interceptor/cache.js b/lib/interceptor/cache.js index 666a87ef3e5..b03734aa886 100644 --- a/lib/interceptor/cache.js +++ b/lib/interceptor/cache.js @@ -19,7 +19,7 @@ module.exports = (opts = {}) => { } = opts if (typeof opts !== 'object' || opts === null) { - throw new TypeError(`expected type of opts to be an Object, got ${store === null ? 'null' : typeof store}`) + throw new TypeError(`expected type of opts to be an Object, got ${opts === null ? 'null' : typeof opts}`) } assertCacheStore(store, 'opts.store')