Skip to content

Commit

Permalink
fix: call explicitly unregister
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx committed Dec 21, 2023
1 parent c5c6648 commit 6565e6d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/compat/dispatcher-weakref.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class CompatFinalizer {
})
}
}

unregister (key) {}
}

module.exports = function () {
Expand Down
9 changes: 7 additions & 2 deletions lib/fetch/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ const { getMaxListeners, setMaxListeners, getEventListeners, defaultMaxListeners

const kAbortController = Symbol('abortController')

const requestFinalizer = new FinalizationRegistry(({ signal, abort }) => {
const requestFinalizer = new FinalizationRegistry(({ signal, abort, controller }) => {
// Currently FinalizationRegistry has a problem and will explicitly 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)
signal.removeEventListener('abort', abort)
})

Expand Down Expand Up @@ -388,7 +393,7 @@ class Request {
} catch {}

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

Expand Down

0 comments on commit 6565e6d

Please sign in to comment.