Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx committed Dec 21, 2023
1 parent 8abfa7d commit f394f77
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/fetch/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ const { getMaxListeners, setMaxListeners, getEventListeners, defaultMaxListeners

const kAbortController = Symbol('abortController')

const requestFinalizer = new FinalizationRegistry(({ signal, abort, controller }) => {
// Currently FinalizationRegistry has a problem and will explicitly call unregister.
// https://github.com/nodejs/node/issues/49344
// https://github.com/nodejs/node/issues/47748
// It will be removed in the future.
requestFinalizer.unregister(controller)
const requestFinalizer = new FinalizationRegistry(({ signal, abort }) => {
signal.removeEventListener('abort', abort)
})

Expand Down Expand Up @@ -376,6 +371,7 @@ class Request {
const abort = function () {
const ac = acRef.deref()
if (ac !== undefined) {
requestFinalizer.unregister(ac)
ac.abort(this.reason)
}
}
Expand All @@ -393,7 +389,7 @@ class Request {
} catch {}

util.addAbortListener(signal, abort)
requestFinalizer.register(ac, { signal, abort, controller: ac })
requestFinalizer.register(ac, { signal, abort })
}
}

Expand Down

0 comments on commit f394f77

Please sign in to comment.