File tree 1 file changed +12
-8
lines changed
1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -277,11 +277,18 @@ impl RawClient {
277
277
return Ok ( ( ) ) ;
278
278
} ;
279
279
280
- self . outstanding_acks . lock ( ) ?. retain_mut ( |ack| {
281
- if ack. id != id {
282
- return true ;
283
- }
280
+ let outstanding_ack = {
281
+ let mut outstanding_acks = self . outstanding_acks . lock ( ) ?;
282
+ outstanding_acks
283
+ . iter ( )
284
+ . position ( |ack| ack. id == id)
285
+ . map ( |pos| outstanding_acks. remove ( pos) )
286
+ } ;
284
287
288
+ // If we found a matching ack, call its callback otherwise ignore it.
289
+ // The official implementation just removes the ack id on timeout:
290
+ // https://github.com/socketio/socket.io-client/blob/main/lib/socket.ts#L467-L495
291
+ if let Some ( mut ack) = outstanding_ack {
285
292
if ack. time_started . elapsed ( ) < ack. timeout {
286
293
if let Some ( ref payload) = socket_packet. data {
287
294
ack. callback . deref_mut ( ) ( Payload :: from ( payload. to_owned ( ) ) , self . clone ( ) ) ;
@@ -293,10 +300,7 @@ impl RawClient {
293
300
}
294
301
}
295
302
}
296
- // nope, just ignore it, the official implment just remove the ack id when timeout
297
- // https://github.com/socketio/socket.io-client/blob/main/lib/socket.ts#L467-L495
298
- false
299
- } ) ;
303
+ }
300
304
301
305
Ok ( ( ) )
302
306
}
You can’t perform that action at this time.
0 commit comments