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

[Fixed] GraphQL Subscriptions: Max Listeners Exceeded Warning #1359

Open
ayoubyoub opened this issue Apr 3, 2020 · 1 comment
Open

[Fixed] GraphQL Subscriptions: Max Listeners Exceeded Warning #1359

ayoubyoub opened this issue Apr 3, 2020 · 1 comment

Comments

@ayoubyoub
Copy link

ayoubyoub commented Apr 3, 2020

Hi

When more than 11 subscriptions occur we get the the node warning "MaxListenersExceededWarning: Possible EventEmitter memory leak detected."

The subscription server looks like this:

const pubsub = new PostgresPubSub({
  host: 'localhost',
  port: process.env.DB_PORT ? parseInt(process.env.DB_PORT) : 5432,
  user: 'testuser',
  password: 'testpassword',
  database: 'whatsapp',
});

[Solution] So i found out that you can change the max listeners in the event emitter of the pubsub instance, like so:

const pubsub = new PostgresPubSub({
  host: 'localhost',
  port: process.env.DB_PORT ? parseInt(process.env.DB_PORT) : 5432,
  user: 'testuser',
  password: 'testpassword',
  database: 'whatsapp',
});

pubsub.ee.setMaxListeners(0); // raise max listeners in event emitter, 0 mean that is limited

Thanks for sharing.
Best regards,

@Urigo
Copy link
Owner

Urigo commented May 15, 2020

mmm maybe it's worth adding a note about running pub/sub in a separate process/engine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants