Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream.eventNames() broken on 21.2.0+ #51302

Open
Qard opened this issue Dec 28, 2023 · 6 comments
Open

stream.eventNames() broken on 21.2.0+ #51302

Qard opened this issue Dec 28, 2023 · 6 comments
Assignees
Labels
confirmed-bug Issues with confirmed bugs. stream Issues and PRs related to the stream subsystem.

Comments

@Qard
Copy link
Member

Qard commented Dec 28, 2023

Version

v21.2.0

Platform

Darwin COMP-JX471G9FQQ 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64 arm Darwin

Subsystem

streams

What steps will reproduce the bug?

Use stream.eventNames() on a stream and you'll find it reports having event listeners for events which it does not actually have listeners for due to this _events pre-allocation change which released in 21.2.0.

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior? Why is that the expected behavior?

stream.eventNames() should only return names of events for which there actually are listeners.

What do you see instead?

All expected event types report having listeners because it's based on Reflect.ownKeys(...) which will see the explicit undefined keys as present and assume that means there are listeners for that event name.

Additional information

No response

@Qard Qard added confirmed-bug Issues with confirmed bugs. stream Issues and PRs related to the stream subsystem. labels Dec 28, 2023
@juanarbol
Copy link
Member

I will try to fix this one

@juanarbol juanarbol self-assigned this Dec 31, 2023
@Medhansh404
Copy link

@juanarbol do you mind if you share how are you planning to approach this issue, do you paln to make changes on the default undefined values or add something/ enhacement that caters to them the undefined listeners so that it won't cause events to be as one? i'm just curious

@juanarbol
Copy link
Member

@juanarbol do you mind if you share how are you planning to approach this issue, do you paln to make changes on the default undefined values or add something/ enhacement that caters to them the undefined listeners so that it won't cause events to be as one? i'm just curious

I don't know yet, I will figure that out later.
I will reference the issue once I have something

@Qard
Copy link
Member Author

Qard commented Jan 1, 2024

I suspect eventNames() is called a lot less frequently than the benefits of that pre-allocation PR, so I would suggest changing eventNames to do a more rigorous check that the keys are not only there but also are non-empty arrays.

@Medhansh404
Copy link

Hey @Qard can you pls tell me a instance where we are using the eventNames(), it will be a lot easier for me if you can do so!!

@IlyasShabi
Copy link
Contributor

@juanarbol I was looking into the issue, and I found myself creating a PR. I'm not sure if it's the right way to do it, but I would like to know how you will fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants