File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
lazer/sdk/rust/client/src Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -97,14 +97,16 @@ impl PythLazerResilientWSConnectionTask {
9797 response_sender : mpsc:: Sender < AnyResponse > ,
9898 request_receiver : & mut mpsc:: Receiver < Request > ,
9999 ) -> Result < ( ) > {
100- let mut last_failure_time = Instant :: now ( ) ;
101-
102100 loop {
101+ let start_time = Instant :: now ( ) ;
103102 if let Err ( e) = self . start ( response_sender. clone ( ) , request_receiver) . await {
104- if last_failure_time. elapsed ( ) > BACKOFF_RESET_DURATION {
103+ // If a connection was working for BACKOFF_RESET_DURATION
104+ // and timeout + 1sec, it was considered successful therefore reset the backoff
105+ if start_time. elapsed ( ) > BACKOFF_RESET_DURATION
106+ && start_time. elapsed ( ) > self . timeout + Duration :: from_secs ( 1 )
107+ {
105108 self . backoff . reset ( ) ;
106109 }
107- last_failure_time = Instant :: now ( ) ;
108110
109111 let delay = self . backoff . next_backoff ( ) ;
110112 match delay {
You can’t perform that action at this time.
0 commit comments