Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Nagy <ronagy@icloud.com>
  • Loading branch information
flakey5 and ronag authored Nov 18, 2024
1 parent 4c3dd04 commit 6ca427c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/interceptor/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 6ca427c

Please sign in to comment.