You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
classTest{privateabortController=newAbortController()publictest(cb: (abortSignal: AbortSignal)=>void,abortSignal: AbortSignal){constsignal=AbortSignal.any([abortSignal,this.abortController.signal])cb(signal)}}constregistry=newFinalizationRegistry((heldValue)=>{console.log(`${heldValue} has been collected`)});(()=>{consttest=newTest()registry.register(test,'test')constabortController=newAbortController()test.test((abortSignal)=>{abortSignal.addEventListener('abort',()=>{console.log(test)})},abortController.signal)})()global.gc?.()setTimeout(()=>{console.log('the end')},2000)
run with node --expose-gc test.ts
How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior? Why is that the expected behavior?
the output should be
test has been collected
the end
because the test object is not referenced anymore
What do you see instead?
output:
the end
the test object is not garbage collected
Additional information
The issues seems to be caused by the cyclic dependency: test object => abortController field => abortSignal => AbortSignal.any result => cb function => test object
AbortSignal.any seems to prevent node from garbage collecting them all at once
The text was updated successfully, but these errors were encountered:
Version
23.10.0
Platform
Subsystem
No response
What steps will reproduce the bug?
run with
node --expose-gc test.ts
How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior? Why is that the expected behavior?
the output should be
because the test object is not referenced anymore
What do you see instead?
output:
the test object is not garbage collected
Additional information
The issues seems to be caused by the cyclic dependency:
test
object =>abortController
field =>abortSignal
=>AbortSignal.any
result =>cb
function =>test
objectAbortSignal.any seems to prevent node from garbage collecting them all at once
The text was updated successfully, but these errors were encountered: