This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
events: use Infinity
for setMaxListeners instead of 0
#22987
Comments
In node v0.10.x and node v0.12.x, both 0 and Infinity are supported:
I'm not sure that slightly simplifying this code is worth not accepting 0 as unlimited and breaking the API. So closing for now, but please feel free to comment further if you still think it would be worth it. |
In lieu of changing the API, perhaps the documentation could at least be updated to recommend using |
jasonkarns
added a commit
to jasonkarns/node
that referenced
this issue
Aug 26, 2015
Instead of recommending `0` as the magic value to set max listeners to unlimited, recommend `Infinity`. This paves the way for `0` as a magic value eventually being deprecated and finally removed closes nodejs/node-v0.x-archive#22987
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Is there a sound reason for choosing
0
as the magic value that disables the max listeners? It's essentially using0
as a special value to representunlimited
but JS already has a perfectly valid number to represent infinity:Infinity
. It would simplify the memory-leak checking as the 0 special case would no longer need checked. Any number would naturally return true forn < Infinity
.The text was updated successfully, but these errors were encountered: