redis / ioredis

🚀 A robust, performance-focused, and full-featured Redis client for Node.js.
MIT License
14.07k stars 1.19k forks source link

`reconnecting` event arguments should include the attempt number #1817

Open loucadufault opened 10 months ago

loucadufault commented 10 months ago

Currently the reconnecting event argument is the time (in ms) before reconnecting. For monitoring purposes, the attempt number is arguably much more important to emit in the logs than the time. For example, if the retryStrategy is a constant delay, knowing that the next reconnect will again happen in 2000ms seems much less valuable than knowing that this is the 10th attempt.

The only way to keep track of the reconnect attempt is by maintaining state externally which is clumsy, or by handling it in the retryStrategy implementation which seems like a hack.

Passing it as the second argument would work