Conversation
1512421 to
1d160da
Compare
|
Things this doesn't solve.
|
metcoder95
left a comment
There was a problem hiding this comment.
It has sense; I just feel that this can cause the false sensation of having a fully fledge dispatcher.
It might be possible that we end with max listeners problems.
Shall we tests the events are emitted as we expect?
|
I feel this is just a hack until we have a better solution. |
|
We would need to have some form of weak event listeners for this to work well. |
|
@benjamingr Do you have any input on how we can have weak event listeners here that when the |
f1e14a3 to
8855481
Compare
|
This is still not great though... until GC the event listeners are still registered. |
|
The alternative is that we have some kind of ref/unref API. But that is going to be a constant pain of people doing it wrong. |
We don't currently expose it but you can use kWeakHandler in the version bundled with Node, that lets you pass a listener and an object that the listener's lifetime is bound to - that's EventTarget though. So we would need to build kWeakHandler (or similar) to EventEmitter and expose that to undici somehow - it has to be baked into the abstraction (EventEmitter) itself - otherwise it leaks the WeakRef itself (as you probably noticed). |
|
@metcoder95 @mcollina wdyt of returning a |
This sounds great, but personally I'm afraid we will be attaching
It simplifies a lot certainly, how does the gc behave (out of curiosity mostly)? |
We cannot say anything definite about gc behavior. It's totally undefined. |
Refs: #3373
Refs: #3370