From f093214cba22ee90408f2d3c44d995ddbddd5766 Mon Sep 17 00:00:00 2001 From: Edsko de Vries Date: Thu, 28 Sep 2023 13:05:05 +0200 Subject: [PATCH] Don't leak exceptions from managed threads --- Network/HTTP2/Arch/Manager.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Network/HTTP2/Arch/Manager.hs b/Network/HTTP2/Arch/Manager.hs index 0b542d00..ef383607 100644 --- a/Network/HTTP2/Arch/Manager.hs +++ b/Network/HTTP2/Arch/Manager.hs @@ -1,4 +1,5 @@ {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} -- | A thread manager. -- The manager has responsibility to spawn and kill @@ -107,9 +108,10 @@ forkManagedUnmask :: Manager -> ((forall x. IO x -> IO x) -> IO ()) -> IO () forkManagedUnmask mgr io = void $ mask_ $ forkIOWithUnmask $ \unmask -> do addMyId mgr - r <- io unmask `onException` deleteMyId mgr + -- We catch the exception and do not rethrow it: we don't want the + -- exception printed to stderr. + io unmask `catch` \(_e :: SomeException) -> return () deleteMyId mgr - return r -- | Adding my thread id to the kill-thread list on stopping. --