Preserve outbound backlog across outages, fix backoff quiet period

This commit is contained in:
2026-08-20 20:12:48 +03:00
parent c030267a77
commit b3aa4c4991
4 changed files with 9 additions and 6 deletions
+3 -1
View File
@@ -15,6 +15,7 @@ import Control.Concurrent.STM
, writeTChan
, writeTVar
)
import Control.Exception (onException)
import Control.Exception.Annotated (throw)
import Control.Lens ((^?))
import Control.Monad (forever)
@@ -38,7 +39,8 @@ readerAction host port token bus =
subscribe bus conn
atomically $ writeTVar (busConn bus) (Just conn)
putStrLn "[reader] connected"
receiveLoop bus conn
-- Unpublish on exit so the writer blocks and the backlog survives the outage.
receiveLoop bus conn `onException` atomically (writeTVar (busConn bus) Nothing)
handshake :: WS.Connection -> String -> IO ()
handshake conn token = do