diff --git a/lib/interceptor/cache.js b/lib/interceptor/cache.js index 0e30a9eb801..c9d2fe47059 100644 --- a/lib/interceptor/cache.js +++ b/lib/interceptor/cache.js @@ -14,18 +14,18 @@ const AGE_HEADER = Buffer.from('age') * @param {import('../../types/dispatcher.d.ts').default.DispatchHandlers} handler */ function sendGatewayTimeout (handler) { - const ac = new AbortController() - const signal = ac.signal - + let aborted = false try { if (typeof handler.onConnect === 'function') { - handler.onConnect(ac.abort) - signal.throwIfAborted() + handler.onConnect(() => { + aborted = true + }) + if (aborted) return } if (typeof handler.onHeaders === 'function') { handler.onHeaders(504, [], () => {}, 'Gateway Timeout') - signal.throwIfAborted() + if (aborted) return } if (typeof handler.onComplete === 'function') {