Skip to content

Commit

Permalink
fix: properly timeout pending ws requests on close
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialPB committed Jan 27, 2025
1 parent fa607d3 commit 88eda80
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class WsClient(

// close the websocket, expire all remaining requests, and unsubscribe from all subscriptions
websocket.close(1000, "Close")
handleTimeouts(0.milliseconds)
handleTimeouts(Duration.ZERO)
requestIdToSubscription.values.forEach { it.stream.unsubscribe() }
}

Expand All @@ -368,7 +368,7 @@ class WsClient(

private fun <T : ExpiringRequest> removeTimedOutRequests(requests: MutableMap<Long, T>, timeout: Duration) {
// skip expiration if timeout is not set or requests is empty
if (!timeout.isPositive() || requests.isEmpty()) {
if (timeout.inWholeMilliseconds < 0 || requests.isEmpty()) {
return
}

Expand Down

0 comments on commit 88eda80

Please sign in to comment.