-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Description
Version
v18.19.1
Platform
Linux spotterT490 6.8.0-38-generic #38-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:25:01 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
node:events
What steps will reproduce the bug?
In node-redis we fire events (such as a connection being made to a server 'connect', the connection being ready 'ready', and the connection being shutdown, 'end') amongst others. In practice, these are proxied to the user from an underlying object.
We have a test to make sure these fires correctly, but that test is failing at the moment in a manner that we can't figure out (but can play around with to get to work, which makes us scratch our head even more)
If I rewrite the test to be
const p1 = once(client, 'connect');
const p2 = once(client, 'ready');
const p3 = once(client, 'end');
await Promise.all([
p1,
p2,
client.connect()
]);
await Promise.all([
p3,
client.close()
]);
the test reliably passes as the once receives the 'end' event that it expects. However, if I rewrite it to be
const p1 = once(client, 'connect');
const p2 = once(client, 'ready');
await Promise.all([
p1,
p2,
client.connect()
]);
const p3 = once(client, 'end');
await Promise.all([
p3,
client.close()
]);
the test now reliably fails again.
In the code in index.ts (that I linked to above) where we listen and refire the events, for 'end' I stuck in a console.log to indicate that the event is being received, and it prints out as expected always, i just don't receive the 'end' event that should be fired unless the test is structured as noted above.
I'm very confused.
How often does it reproduce? Is there a required condition?
always as noted
What is the expected behavior? Why is that the expected behavior?
the promise that events.once() returns should be satisfied.
What do you see instead?
event promise not being satisfied.
Additional information
No response