Skip to content

Commit

Permalink
integration: Wait for websocket to be connected before calling the co…
Browse files Browse the repository at this point in the history
…ntinuation
  • Loading branch information
akshaymankar committed Jan 8, 2025
1 parent 0e53d4f commit c3734bb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions integration/test/Test/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ createEventsWebSocket user cid = do
ackChan <- liftIO newEmptyMVar
serviceMap <- lift $ getServiceMap =<< objDomain user
apiVersion <- lift $ getAPIVersionFor $ objDomain user
wsStarted <- newEmptyMVar
let minAPIVersion = 8
lift
. when (apiVersion < minAPIVersion)
Expand All @@ -538,7 +539,8 @@ createEventsWebSocket user cid = do
let HostPort caHost caPort = serviceHostPort serviceMap Cannon
path = "/v" <> show apiVersion <> "/events" <> maybe "" ("?client=" <>) cid
caHdrs = [(fromString "Z-User", toByteString' uid)]
app conn =
app conn = do
putMVar wsStarted ()
race_
(wsRead conn `catch` (writeChan eventsChan . Left))
(wsWrite conn)
Expand Down Expand Up @@ -571,7 +573,8 @@ createEventsWebSocket user cid = do
)
k

Codensity $ \k ->
Codensity $ \k -> do
takeMVar wsStarted
k (EventWebSocket eventsChan ackChan) `finally` do
putMVar ackChan Nothing
liftIO $ wait wsThread
Expand Down

0 comments on commit c3734bb

Please sign in to comment.