From 5c45d968836a651d5820c7b0ede222153c909fcc Mon Sep 17 00:00:00 2001 From: Firdavs Khaydarov Date: Wed, 5 Apr 2023 15:30:34 +0300 Subject: [PATCH] added retry count resetting --- Sources/EventSource/EventSource.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/EventSource/EventSource.swift b/Sources/EventSource/EventSource.swift index a40a071..c3fed97 100644 --- a/Sources/EventSource/EventSource.swift +++ b/Sources/EventSource/EventSource.swift @@ -172,6 +172,9 @@ public final class EventSource { // Stop connection when 204 response code, otherwise keep open if httpResponse.statusCode != 204, 200...299 ~= httpResponse.statusCode { + // Reset current retries count to allow retry on the next error + currentRetryCount = 0 + if readyState != .open { await setOpen() }