Skip to content

Commit d2737d4

Browse files
committed
fix: call explicitly unregister
1 parent c5c6648 commit d2737d4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/compat/dispatcher-weakref.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class CompatFinalizer {
2828
})
2929
}
3030
}
31+
32+
unregister (key) {}
3133
}
3234

3335
module.exports = function () {

lib/fetch/request.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ const { getMaxListeners, setMaxListeners, getEventListeners, defaultMaxListeners
3434

3535
const kAbortController = Symbol('abortController')
3636

37-
const requestFinalizer = new FinalizationRegistry(({ signal, abort }) => {
37+
const requestFinalizer = new FinalizationRegistry(({ signal, abort, controller }) => {
38+
// Currently FinalizationRegistry has a problem and will explicitly unregister.
39+
// https://github.com/nodejs/node/issues/49344
40+
// https://github.com/nodejs/node/issues/47748
41+
// It will be removed in the future.
42+
requestFinalizer.unregister(controller)
3843
signal.removeEventListener('abort', abort)
3944
})
4045

@@ -388,7 +393,7 @@ class Request {
388393
} catch {}
389394

390395
util.addAbortListener(signal, abort)
391-
requestFinalizer.register(ac, { signal, abort })
396+
requestFinalizer.register(ac, { signal, abort, controller: ac })
392397
}
393398
}
394399

0 commit comments

Comments
 (0)