[HOTFIX] Change factor to 1 as any number higher cause an overflow#37
[HOTFIX] Change factor to 1 as any number higher cause an overflow#37sergicastellsague wants to merge 1 commit intorikulo:masterfrom
Conversation
|
According to the JS's implementation, it did this without any issue - https://github.com/mokesmokes/backo/blob/master/index.js#L24 Do you have any test case? |
|
Hey there, We don't need tests for this. Pretty simple maths. If factor is 2 and the attemps counter is 50, the result of this math operation is 50^50. The number will fit in the "num", but if you check the code further, you'll see it's being used for the Duration in a timer. And Duration is initialized with an int value, not a num. And an int has a pretty low limit that you reach easily. |
|
But the returned value of the socket.io-client-dart/lib/src/manager.dart Line 577 in 6980fbb |
|
Right. I just tried again and it does not fail that further.
Then it all explodes in here: I guess duration cannot handle a negative number |
|
so, maybe we simply add the following code to avoid that case. |
|
That'd work as well. As a hotfix it seems to be a good approach as well. What I am afraid of is that this backoff needs a rethought. What do you think about getting rid of the factor? This exponential value doesn't make much sense to me. |
|
No, the fixed you did will be |


There's a bug in the library, in which after around 54 retries, the WebSocket does stop trying reconnecting.
It does stop because of the backoff ms.
var ms = _ms * Math.pow(_factor, this.attempts++);The real fix would be changing the duration method. This is a hotfix.