Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/handler/cache-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ class CacheHandler extends DecoratorHandler {
this.#handler = handler
}

onConnect (abort) {
onConnect (...args) {
if (this.#writeStream) {
this.#writeStream.destroy()
this.#writeStream = undefined
}

if (typeof this.#handler.onConnect === 'function') {
this.#handler.onConnect(abort)
this.#handler.onConnect(...args)
}
}

Expand Down
24 changes: 9 additions & 15 deletions lib/handler/retry-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class RetryHandler {
this.opts = { ...dispatchOpts, body: wrapRequestBody(opts.body) }
this.abort = null
this.aborted = false
this.connectCalled = false
this.retryOpts = {
retry: retryFn ?? RetryHandler[kRetryHandlerDefaultRetry],
retryAfter: retryAfter ?? true,
Expand Down Expand Up @@ -68,16 +69,6 @@ class RetryHandler {
this.end = null
this.etag = null
this.resume = null

// Handle possible onConnect duplication
this.handler.onConnect(reason => {
this.aborted = true
if (this.abort) {
this.abort(reason)
} else {
this.reason = reason
}
})
}

onRequestSent () {
Expand All @@ -92,11 +83,14 @@ class RetryHandler {
}
}

onConnect (abort) {
if (this.aborted) {
abort(this.reason)
} else {
this.abort = abort
onConnect (abort, context) {
this.abort = abort
if (!this.connectCalled) {
this.connectCalled = true
this.handler.onConnect(reason => {
this.aborted = true
this.abort(reason)
}, context)
}
}

Expand Down
Loading