#1091·kue

Redis connection lost and command aborted. code: 'UNCERTAIN_STATE'

Author: pallavi2209Created Jul 20, 2017Updated Jan 29, 2021

We have a node.js app deployed on Heroku and we are using kue to run some background jobs. It usually works fine, but few days back we saw following errors in our production server:

Jul 10 11:19:23 refocus app/web.6: Error removing 4628051 { AbortError: Redis connection lost and command aborted. It might have been processed. 
Jul 10 11:19:23 refocus app/web.6:     at RedisClient.flush_and_error (/app/node_modules/kue/node_modules/redis/index.js:357:23) 
Jul 10 11:19:23 refocus app/web.6:     at RedisClient.connection_gone (/app/node_modules/kue/node_modules/redis/index.js:659:14) 
Jul 10 11:19:23 refocus app/web.6:     at Socket.<anonymous> (/app/node_modules/kue/node_modules/redis/index.js:293:14) 
Jul 10 11:19:23 refocus app/web.6:     at Socket.g (events.js:286:16) 
Jul 10 11:19:23 refocus app/web.6:     at emitNone (events.js:91:20) 
Jul 10 11:19:23 refocus app/web.6:     at Socket.emit (events.js:185:7) 
Jul 10 11:19:23 refocus app/web.6:     at endReadableNT (_stream_readable.js:975:12) 
Jul 10 11:19:23 refocus app/web.6:     at _combinedTickCallback (internal/process/next_tick.js:74:11) 
Jul 10 11:19:23 refocus app/web.6:     at process._tickDomainCallback [as _tickCallback] (internal/process/next_tick.js:122:9) 
Jul 10 11:19:23 refocus app/web.6:   code: 'UNCERTAIN_STATE', 
Jul 10 11:19:23 refocus app/web.6:   command: 'EXEC', 
Jul 10 11:19:23 refocus app/web.6:   errors:  
Jul 10 11:19:23 refocus app/web.6:    [ { AbortError: Redis connection lost and command aborted. It might have been processed. 
Jul 10 11:19:23 refocus app/web.6:          at RedisClient.flush_and_error (/app/node_modules/kue/node_modules/redis/index.js:357:23) 
Jul 10 11:19:23 refocus app/web.6:          at RedisClient.connection_gone (/app/node_modules/kue/node_modules/redis/index.js:659:14) 
Jul 10 11:19:23 refocus app/web.6:          at Socket.<anonymous> (/app/node_modules/kue/node_modules/redis/index.js:293:14) 
Jul 10 11:19:23 refocus app/web.6:          at Socket.g (events.js:286:16) 
Jul 10 11:19:23 refocus app/web.6:          at emitNone (events.js:91:20) 
Jul 10 11:19:23 refocus app/web.6:          at Socket.emit (events.js:185:7) 
Jul 10 11:19:23 refocus app/web.6:          at endReadableNT (_stream_readable.js:975:12) 
Jul 10 11:19:23 refocus app/web.6:          at _combinedTickCallback (internal/process/next_tick.js:74:11) 
Jul 10 11:19:23 refocus app/web.6:          at process._tickDomainCallback [as _tickCallback] (internal/process/next_tick.js:122:9) 
Jul 10 11:19:23 refocus app/web.6:        code: 'UNCERTAIN_STATE', 
Jul 10 11:19:23 refocus app/web.6:        command: 'ZREM', 
Jul 10 11:19:23 refocus app/web.6:        args: [Object], 
Jul 10 11:19:23 refocus app/web.6:        position: 0 },  .............

We have seen these 'UNCERTAIN_STATE' errors before as well. I went through other related issues and it seems a network problem, but since it looks like it is coming from kue, I just wanted to confirm whether we have some potential options to prevent this in future.