Skip to content

feat(pubsub): add maxListeners to subscription eventEmitter#688

Merged
benjie merged 2 commits intographile:v4from
xvaara:patch-1
Nov 11, 2020
Merged

feat(pubsub): add maxListeners to subscription eventEmitter#688
benjie merged 2 commits intographile:v4from
xvaara:patch-1

Conversation

@xvaara
Copy link
Copy Markdown
Contributor

@xvaara xvaara commented Nov 11, 2020

Description

As talked in discord. If multiple subscription to same topic (over 10 as default), you get a warning:

(node:42281) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 graphql:projectList listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit

Performance impact

unknown

Security impact

unknown

Checklist

  • My code matches the project's code style and yarn lint:fix passes.
  • I've added tests for the new feature, and yarn test passes.
  • I have detailed the new feature in the relevant documentation.
  • I have added this feature to 'Pending' in the RELEASE_NOTES.md file (if one exists).
  • If this is a breaking change I've explained why.

Add maxListeners to subscription eventEmitter
Copy link
Copy Markdown
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great @xvaara; could you also detail it in the pg-pubsub README please? Then we're good to merge 👍

Comment thread packages/pg-pubsub/src/index.ts Outdated

["postgraphile:options"](incomingOptions, { pgPool }) {
const eventEmitter = new EventEmitter();
if (incomingOptions.subscriptionEventEmitterMaxListeners) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to allow 0 here, I think?

Suggested change
if (incomingOptions.subscriptionEventEmitterMaxListeners) {
if (incomingOptions.subscriptionEventEmitterMaxListeners != null) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed.

Copy link
Copy Markdown
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 🙌

@benjie benjie changed the title Add maxListeners to subscription eventEmitter feat(pubsub): add maxListeners to subscription eventEmitter Nov 11, 2020
@benjie benjie merged commit 576177f into graphile:v4 Nov 11, 2020
@xvaara xvaara deleted the patch-1 branch November 11, 2020 20:00
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

Successfully merging this pull request may close these issues.

2 participants