@@ -34,11 +34,7 @@ class ConnectionPool {
3434 this . _ssl = opts . ssl
3535 this . _agent = opts . agent
3636 // the resurrect timeout is 60s
37- // we multiply it by 2 because the resurrect formula is
38- // `Math.pow(resurrectTimeout * 2, deadCount -1)`
39- // and we don't need to multiply by 2
40- // the resurrectTimeout every time
41- this . resurrectTimeout = 1000 * 60 * 2
37+ this . resurrectTimeout = 1000 * 60
4238 // number of consecutive failures after which
4339 // the timeout doesn't increase
4440 this . resurrectTimeoutCutoff = 5
@@ -94,15 +90,9 @@ class ConnectionPool {
9490 connection . status = Connection . statuses . DEAD
9591 connection . deadCount ++
9692 // resurrectTimeout formula:
97- // `Math.pow(resurrectTimeout * 2, deadCount -1)`
98- // we don't need to multiply the resurrectTimeout by 2
99- // every time, it is cached during the initialization
100- connection . resurrectTimeout = Date . now ( ) + Math . pow (
101- this . resurrectTimeout ,
102- Math . min (
103- connection . deadCount - 1 ,
104- this . resurrectTimeoutCutoff
105- )
93+ // `resurrectTimeout * 2 ** min(deadCount - 1, resurrectTimeoutCutoff)`
94+ connection . resurrectTimeout = Date . now ( ) + this . resurrectTimeout * Math . pow (
95+ 2 , Math . min ( connection . deadCount - 1 , this . resurrectTimeoutCutoff )
10696 )
10797
10898 // sort the dead list in ascending order
0 commit comments