@@ -18,6 +18,7 @@ import Control.Concurrent.STM
1818import Control.Exception (Exception, SomeException(..), AsyncException(..), throwIO)
1919import qualified Control.Exception as E
2020import Control.Monad (void, when)
21+import Data.Maybe (fromMaybe)
2122import Data.Typeable
2223import qualified Network.HTTP.Types as H
2324import Network.HTTP2
@@ -93,8 +94,9 @@ runStream Context{outputQ} mkOutput tickle strm s h trailers strmbdy = do
9394 -- Run the stream body, use its result to construct the trailers, and
9495 -- re-raise any Exception so it will still be handled later.
9596 x <- E.try $ strmbdy write flush
96− atomically $ writeTBQueue sq $ SFinish $ trailers x
97− either throwIO (void . return) x
97+ case (x, trailers x) of
98+ (Left exc, Nothing) -> throwIO exc
99+ (_, mts) -> atomically $ writeTBQueue sq $ SFinish $ fromMaybe [] mts
98100
99101-- | Handle abnormal termination of a stream: mark it as closed, send a reset
100102-- frame, and call the user's 'settingsOnException' handler if applicable.