3

I just ran into a situation where a client connected to our Apollo Server api was opening a new subscription listener every 3 seconds. This quickly exceeded the maxListeners for the PubSub instance on the server.

I see this message in the console: (node:97536) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 6 TRUCK_TELEMETRY listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit.

I would like to hook into the PubSub in some way to log further information and possibly throw an error when maxListeners is exceeded. I'm not sure how to do this, and I'm having a hard time finding documentation.

SlothFriend
  • 601
  • 1
  • 7
  • 14
  • 1
    already answered https://stackoverflow.com/a/43763782/6124657 ? – xadm Jan 23 '20 at 22:25
  • Not an exact dupe but the answer to that post still rings true -- you shouldn't utilize the in-memory `PubSub` implementation in production. – Daniel Rearden Jan 23 '20 at 23:50
  • 1
    @xadm I am aware of that post, and it does not answer my question. It shows how to set maxListeners, but that just changes when the node warning is thrown. I'd really like a way to hook into the EventEmitter so I can perform actions when this condition is met. – SlothFriend Jan 24 '20 at 00:21

0 Answers0