Skip to content

Commit

Permalink
Cancel PGListener reader async when a subscription is stopped
Browse files Browse the repository at this point in the history
This avoids asyncs building up over time
  • Loading branch information
mpscholten committed Feb 5, 2022
1 parent 3c77188 commit b7e1ccf
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions IHP/PGListener.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b7e1ccf

Please sign in to comment.