Possible EventEmitter memory leak detected

Issue #824 resolved
Gerben Wichers created an issue

Since a couple of days I see that my poste docker is using 100% CPU load.

It is running correctly for some time, and after a while (do not know exactly how long) the CPU load goes up.
Looking at the docker log, I see the following error:

(node:1108) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
at _addListener (events.js:389:17)
at RedisClient.addListener (events.js:405:10)
at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
at RedisClient.emit (events.js:314:20)
at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)
(node:1096) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
at _addListener (events.js:389:17)
at RedisClient.addListener (events.js:405:10)
at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
at RedisClient.emit (events.js:314:20)
at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)

I'm running version 2.2.26 FREE of Poste.io on Docker version 19.03.14

Comments (16)

  1. Gerben Wichers reporter
    • changed status to open

    After updating to 2.2.27 FREE still the same error:

    [services.d] done.
    (node:1159) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:389:17)
    at RedisClient.addListener (events.js:405:10)
    at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    at RedisClient.emit (events.js:314:20)
    at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
    at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
    at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
    at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
    at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)
    (node:1170) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:389:17)
    at RedisClient.addListener (events.js:405:10)
    at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    at RedisClient.emit (events.js:314:20)
    at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
    at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
    at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
    at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
    at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)
    

  2. Iñaki Martinez Diez

    Hello,

    I have the same error (i downloaded yesterday latest image):

    (node:693) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:389:17)
    at RedisClient.addListener (events.js:405:10)
    at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    at RedisClient.emit (events.js:314:20)
    at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
    at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
    at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
    at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
    at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)
    (node:688) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:389:17)
    at RedisClient.addListener (events.js:405:10)
    at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    at RedisClient.emit (events.js:314:20)
    at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
    at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
    at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
    at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
    at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)

    Container stop so NO mail service for 13 hours…….. 😞 , is it a good idea to use “--restart=always“ or any other restart method ? (documentation says nothing)

    Regards.

  3. Gerben Wichers reporter

    I still have these errors in the log.

    I’m now running version 2.2.30

    (node:1568) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:389:17)
    at RedisClient.addListener (events.js:405:10)
    at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    at RedisClient.emit (events.js:314:20)
    at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
    at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
    at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
    at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
    at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)
    (node:1572) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:389:17)
    at RedisClient.addListener (events.js:405:10)
    at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    at RedisClient.emit (events.js:314:20)
    at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
    at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
    at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
    at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
    at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)
    

  4. 你说

    I also encountered these problems. When I send a lot of emails, I get stuck and cannot send. I have to restart docker to restore it to normal.

  5. Alexander Kuryzhev

    Same problem. with latest image version

    mailserver | (node:658) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    mailserver | at _addListener (events.js:389:17)
    mailserver | at RedisClient.addListener (events.js:405:10)
    mailserver | at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    mailserver | at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:179:13)
    mailserver | at RedisClient.emit (events.js:314:20)
    mailserver | at RedisClient.on_error (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:341:14)
    mailserver | at Socket.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:222:14)
    mailserver | at Socket.emit (events.js:314:20)
    mailserver | at emitErrorNT (internal/streams/destroy.js:92:8)
    mailserver | at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    mailserver | (node:669) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    mailserver | at _addListener (events.js:389:17)
    mailserver | at RedisClient.addListener (events.js:405:10)
    mailserver | at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    mailserver | at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:179:13)
    mailserver | at RedisClient.emit (events.js:314:20)
    mailserver | at RedisClient.on_error (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:341:14)
    mailserver | at Socket.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:222:14)
    mailserver | at Socket.emit (events.js:314:20)
    mailserver | at emitErrorNT (internal/streams/destroy.js:92:8)
    mailserver | at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)

  6. Alejandro Santa-Cruz

    same here:

    docker logs --tail=100 mail
    

    (node:2759) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:389:17)
    at RedisClient.addListener (events.js:405:10)
    at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    at RedisClient.emit (events.js:314:20)
    at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
    at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
    at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
    at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
    at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)
    (node:2758) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:389:17)
    at RedisClient.addListener (events.js:405:10)
    at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    at RedisClient.emit (events.js:314:20)
    at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
    at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
    at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
    at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
    at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)

  7. Gerben Wichers reporter

    Error still exists after updating to Version 2.3.0

    [services.d] done.
    (node:1381) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:389:17)
    at RedisClient.addListener (events.js:405:10)
    at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    at RedisClient.emit (events.js:314:20)
    at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
    at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
    at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
    at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
    at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)
    (node:1385) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pmessage listeners added to [RedisClient]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:389:17)
    at RedisClient.addListener (events.js:405:10)
    at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:148:18
    at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    at RedisClient.emit (events.js:314:20)
    at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:671:14)
    at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:729:9)
    at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:761:9)
    at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:137:18)
    at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)
    

  8. Mydayyy

    Running into the same issue on latest.

    This might be related: Every two minutes, I receive this error from haraka-smtp:

    2021-10-10 04:00:01.873894500  [INFO] [-] [redis] Disconnected from redis://127.0.0.1:6379
    2021-10-10 04:00:01.883697500  [INFO] [-] [karma] Disconnected from redis://127.0.0.1:6379
    2021-10-10 04:00:02.076214500  [INFO] [-] [redis] connected to redis://127.0.0.1:6379
    2021-10-10 04:00:02.085518500  [DEBUG] [-] [watch] psubscribed to result-*
    2021-10-10 04:00:02.085596500  [ERROR] [-] [server] watch plugin ran callback multiple times - ignoring subsequent calls
    2021-10-10 04:00:02.086628500  [ERROR] [-] [server] Error
    2021-10-10 04:00:02.086647500      at callback (/usr/lib/node_modules/Haraka/plugins.js:482:34)
    2021-10-10 04:00:02.086651500      at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:273:5
    2021-10-10 04:00:02.086655500      at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    2021-10-10 04:00:02.086658500      at RedisClient.emit (events.js:314:20)
    2021-10-10 04:00:02.086661500      at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:672:14)
    2021-10-10 04:00:02.086664500      at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:730:9)
    2021-10-10 04:00:02.086667500      at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:762:9)
    2021-10-10 04:00:02.086670500      at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:138:18)
    2021-10-10 04:00:02.086673500      at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)
    2021-10-10 04:00:02.086675500      at Socket.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:219:27)
    2021-10-10 04:00:02.087963500  [INFO] [-] [karma] connected to redis://127.0.0.1:6379
    

    If you need more infos I’d be willing to help debug this

  9. Ilkka Myller

    In the past this issue caused Poste to crash completely, but they’ve been attempting workarounds at least in:

    2.2.23 - 20200925

    • regularly clear redis pubsub connections

    2.2.20 - 20200603

    • fix redis subscribed connections overflow

    These previous fixes allowed our production mail servers to stay up and running but the “Possible EventEmitter memory leak detected” errors have continued ever since.

    Preferred result would be to fix the root cause of these errors completely.

    Currently running:
    Version 2.3.4 PRO # 1507

  10. Samuel L. / SSH

    2021-12-28 18:30:01.839450500  [ERROR] [-] [server] watch plugin ran callback multiple times - ignoring subsequent calls
    2021-12-28 18:30:01.839451500  [ERROR] [-] [server] Error
    2021-12-28 18:30:01.839452500      at callback (/usr/lib/node_modules/Haraka/plugins.js:482:34)
    2021-12-28 18:30:01.839453500      at /usr/lib/node_modules/Haraka/node_modules/haraka-plugin-watch/index.js:273:5
    2021-12-28 18:30:01.839454500      at RedisClient.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/haraka-plugin-redis/index.js:183:13)
    2021-12-28 18:30:01.839455500      at RedisClient.emit (events.js:314:20)
    2021-12-28 18:30:01.839456500      at subscribe_unsubscribe (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:672:14)
    2021-12-28 18:30:01.839457500      at return_pub_sub (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:730:9)
    2021-12-28 18:30:01.839458500      at RedisClient.return_reply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:762:9)
    2021-12-28 18:30:01.839459500      at JavascriptRedisParser.returnReply (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:138:18)
    2021-12-28 18:30:01.839460500      at JavascriptRedisParser.execute (/usr/lib/node_modules/Haraka/node_modules/redis-parser/lib/parser.js:544:14)
    2021-12-28 18:30:01.839461500      at Socket.<anonymous> (/usr/lib/node_modules/Haraka/node_modules/redis/index.js:219:27)
    2021-12-28 18:30:01.847539500  [INFO] [-] [limit] connected to redis://127.0.0.1:6379/4
    

    The time has come, this caused multiple instances of Poste.io to stop working (see issue #913 and probably some others), without even crashing. Maybe this log could be of some help. It’s from Haraka SMTP and happens once every about 2 minutes give/take a bit of time.

  11. David Tchekachev

    Hi,
    I am having the same issue error logs as Samuel in both haraka-smtp and haraka-submission which doesn’t seem to block email delivery but the UI isn’t able to pickup the live emails on the admin landing page.

    Version 2.3.6 FREE # 1656

    Is there a separate issue already open for this error or does it need to be created ?

    Thx

  12. David Tchekachev

    Correct, the Version 2.3.7 FREE # 1715 got deployed while I was writing my comment.
    Now everything is working, thank you so much

  13. Log in to comment