From b7e1ccf20a624ecb129c92545b653a039b2dde1c Mon Sep 17 00:00:00 2001 From: Marc Scholten Date: Sat, 5 Feb 2022 11:44:19 +0100 Subject: [PATCH] Cancel PGListener reader async when a subscription is stopped This avoids asyncs building up over time --- IHP/PGListener.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/IHP/PGListener.hs b/IHP/PGListener.hs index b15a627e0..7656f7acc 100644 --- a/IHP/PGListener.hs +++ b/IHP/PGListener.hs @@ -164,6 +164,7 @@ unsubscribe subscription@(Subscription { .. }) pgListener = do deleteById :: [Subscription] -> [Subscription] deleteById = List.deleteBy (\a b -> get #id a == get #id b) subscription modifyIORef' (get #subscriptions pgListener) (HashMap.adjust deleteById channel) + uninterruptibleCancel reader pure () -- | Runs a @LISTEN ..;@ statements on the postgres connection, if not already listening on that channel