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
const{ channel }=require('diagnostics_channel')conststrongRef=channel('strong')strongRef.subscribe(message=>{console.log(message)// outputs because the subscriber is still available})channel('weak').subscribe(message=>{console.log(message)// no output because the subscriber was garbage collected})setTimeout(()=>{channel('weak').publish('weak output')strongRef.publish('strong output')})gc()
How often does it reproduce? Is there a required condition?
Whenever a channel is used multiple times without a strong reference to the returned object and with any garbage collection happening between uses.
What is the expected behavior?
It should be possible to reference channels by name and expect them to be retained without explicitly holding a reference to the returned value of the function.
What do you see instead?
Channels are seemingly randomly removed whenever garbage collection happens if there is no strong reference to the returned channel.
Additional information
Every single member in my team got bit by this at one point or another. This is also true for external users trying to contribute to our repository or to other libraries, for example DataDog/dd-trace-js#1642 (comment).
My understanding is this was done to allow dynamic channel names that would later be garbage collected. Unfortunately, this resulted in this bug. Since dynamic channel names is an edge case, I think the priority should be on fixing the bug, and if anyone actually needs dynamic channel names then there could be a method added to cleanup channels by name, or to explicitly make them weak references.
cc @Qard since he did the original implementation.
The text was updated successfully, but these errors were encountered:
Version
17.6.0
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Whenever a channel is used multiple times without a strong reference to the returned object and with any garbage collection happening between uses.
What is the expected behavior?
It should be possible to reference channels by name and expect them to be retained without explicitly holding a reference to the returned value of the function.
What do you see instead?
Channels are seemingly randomly removed whenever garbage collection happens if there is no strong reference to the returned channel.
Additional information
Every single member in my team got bit by this at one point or another. This is also true for external users trying to contribute to our repository or to other libraries, for example DataDog/dd-trace-js#1642 (comment).
My understanding is this was done to allow dynamic channel names that would later be garbage collected. Unfortunately, this resulted in this bug. Since dynamic channel names is an edge case, I think the priority should be on fixing the bug, and if anyone actually needs dynamic channel names then there could be a method added to cleanup channels by name, or to explicitly make them weak references.
cc @Qard since he did the original implementation.
The text was updated successfully, but these errors were encountered: