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.