Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
High number of event handlers problematic?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Felix E. Klee  
View profile  
 More options Nov 15 2012, 4:22 am
From: "Felix E. Klee" <felix.k...@inka.de>
Date: Thu, 15 Nov 2012 10:21:32 +0100
Local: Thurs, Nov 15 2012 4:21 am
Subject: High number of event handlers problematic?
Node reports:

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

That there are more than 10 event listeners in my app is no surprise:
For every Socket.IO socket, I set up `n` listeners on "connect" to the
Redis database. The number `n` is around 10 (it corresponds to the
number of certain Redis keys).

To sum up, with every client (browser) connect, about 10 listeners for
the Redis "connect" event are added. So in the end, there may be
thousands of listeners for the Redis "connect" event.

I'd like to keep it that way, as the solution appears simple and robust.

However the above warning makes me suspicious: Is the solution no so
robust after all? Are there potential problems?

Or could I just do `emitter.setMaxListeners(0)`, and that's it?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Noordhuis  
View profile  
 More options Nov 15 2012, 8:45 am
From: Ben Noordhuis <i...@bnoordhuis.nl>
Date: Thu, 15 Nov 2012 14:45:25 +0100
Local: Thurs, Nov 15 2012 8:45 am
Subject: Re: [nodejs] High number of event handlers problematic?
On Thu, Nov 15, 2012 at 10:21 AM, Felix E. Klee <felix.k...@inka.de> wrote:

Don't read too much into it, it's just a warning.  If you have a
legitimate reason to add 10+ listeners, go ahead and increase
maxListeners.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fedor Indutny  
View profile  
 More options Nov 15 2012, 8:49 am
From: Fedor Indutny <fe...@indutny.com>
Date: Thu, 15 Nov 2012 17:48:37 +0400
Local: Thurs, Nov 15 2012 8:48 am
Subject: Re: [nodejs] High number of event handlers problematic?

It's very roboust, it's just to debug event listener leaks, which may
happen if you're attaching the same listener to the same event emitter over
and over again.

Cheers,
Fedor.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Felix E. Klee  
View profile  
 More options Nov 15 2012, 4:41 pm
From: "Felix E. Klee" <felix.k...@inka.de>
Date: Thu, 15 Nov 2012 22:40:27 +0100
Local: Thurs, Nov 15 2012 4:40 pm
Subject: Re: [nodejs] High number of event handlers problematic?
On Thu, Nov 15, 2012 at 2:48 PM, Fedor Indutny <fe...@indutny.com>
wrote:

> it's just to debug event listener leaks, which may happen
> if you're attaching the same listener to the same event emitter over and
> over again.

I just set `redisClient.setMaxListeners(0)`, until I thought again, and:

That warning actually makes sense! My app does have a leak:

The problem is that new event listeners are added on every Socket.IO
connection (= browser connection). But: When a browser disconnects, then
that is not registered, and the listeners persist. Now I wonder how to
avoid that problem:

https://groups.google.com/forum/#!topic/socket_io/S5G6f4YJdvo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »