diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,13 +1,28 @@
 # Change log for "tls"
 
-## Version 2.5.3
+## Version 2.6.0
 
+The early data sizes are `Word32`, and `HasBackend` has a new method with a default.
+`bye` waits for the last handshake messages only with a backend which has it.
+
 * Count milliseconds from the base without overflowing a 32-bit time_t.
   [#644](https://github.com/haskell-tls/hs-tls/pull/644)
+* Use Word32 for the early data sizes.
+  [#645](https://github.com/haskell-tls/hs-tls/pull/645)
 * Use a generator of no small order in the custom DH prime test.
   [#646](https://github.com/haskell-tls/hs-tls/pull/646)
+* Let bye give up on a receive without interrupting it.
+  [#647](https://github.com/haskell-tls/hs-tls/pull/647)
 * Encode the test certificates as v3.
   [#648](https://github.com/haskell-tls/hs-tls/pull/648)
+* Take the STM action last in getBackendRecvWith, whatever its result.
+  [#650](https://github.com/haskell-tls/hs-tls/pull/650)
+* Give up in bye only through getBackendRecvWith, and give Socket one.
+  [#651](https://github.com/haskell-tls/hs-tls/pull/651)
+* Use the native I/O manager for the tests on Windows.
+  [#652](https://github.com/haskell-tls/hs-tls/pull/652)
+* Bound network-run and hpke for the utilities.
+  [#653](https://github.com/haskell-tls/hs-tls/pull/653)
 
 ## Version 2.5.2
 
diff --git a/Network/TLS.hs b/Network/TLS.hs
--- a/Network/TLS.hs
+++ b/Network/TLS.hs
@@ -8,9 +8,9 @@
 -- use of the advanced type system, high level constructions and
 -- common Haskell features.
 --
--- Currently implement the TLS1.2 and TLS 1.3
--- protocol, and support RSA and Ephemeral (Elliptic curve and
--- regular) Diffie Hellman key exchanges, and many extensions.
+-- It currently implements TLS 1.2 and TLS 1.3, supports RSA and
+-- ephemeral (elliptic curve and finite field) Diffie-Hellman key
+-- exchanges, and many extensions.
 --
 -- The typical usage is:
 --
@@ -18,7 +18,7 @@
 -- > ctx <- contextNew socket <params>
 -- > handshake ctx
 -- > ... (using recvData and sendData)
--- > bye
+-- > bye ctx
 module Network.TLS (
     -- * Basic APIs
     Context,
@@ -34,6 +34,7 @@
 
     -- * Backend abstraction
     HasBackend (..),
+    RecvWith (..),
     Backend (..),
 
     -- * Parameters
@@ -332,7 +333,7 @@
 import Data.X509 (ExtKeyUsagePurpose (..), PrivKey (..), PubKey (..))
 import Data.X509.Validation hiding (HostName, defaultHooks)
 
-import Network.TLS.Backend (Backend (..), HasBackend (..))
+import Network.TLS.Backend (Backend (..), HasBackend (..), RecvWith (..))
 import Network.TLS.Cipher
 import Network.TLS.Compression (
     Compression (..),
@@ -375,7 +376,7 @@
 import Network.TLS.Types
 import Network.TLS.X509
 
-{-# DEPRECATED Bytes "Use Data.ByteString.Bytestring instead of Bytes." #-}
+{-# DEPRECATED Bytes "Use Data.ByteString.ByteString instead of Bytes." #-}
 type Bytes = ByteString
 
 -- | Getting certificates from a client, if any.
@@ -385,11 +386,13 @@
 getClientCertificateChain :: Context -> IO (Maybe CertificateChain)
 getClientCertificateChain ctx = usingState_ ctx S.getClientCertificateChain
 
+-- | Getting certificates from a server, if any.
+--   A server sends no certificate on resumption; then this returns 'Nothing'.
 getServerCertificateChain :: Context -> IO (Maybe CertificateChain)
 getServerCertificateChain ctx = usingState_ ctx S.getServerCertificateChain
 
 -- $exceptions
 --     Since 1.8.0, this library only throws exceptions of type 'TLSException'.
---     In the common case where the chosen backend is socket, 'IOException'
+--     In the common case where the chosen backend is socket, 'Control.Exception.IOException'
 --     may be thrown as well. This happens because the backend for sockets,
 --     opaque to most modules in the @tls@ library, throws those exceptions.
diff --git a/Network/TLS/Backend.hs b/Network/TLS/Backend.hs
--- a/Network/TLS/Backend.hs
+++ b/Network/TLS/Backend.hs
@@ -1,8 +1,12 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE RankNTypes #-}
+
 -- | A Backend represents a unified way to do IO on different
 -- types without burdening our calling API with multiple
 -- ways to initialize a new context.
 --
 -- Typically, a backend provides:
+--
 -- * a way to read data
 -- * a way to write data
 -- * a way to close the stream
@@ -10,8 +14,10 @@
 module Network.TLS.Backend (
     HasBackend (..),
     Backend (..),
+    RecvWith (..),
 ) where
 
+import Control.Concurrent.STM (STM)
 import qualified Data.ByteString as B
 import qualified Network.Socket as Network
 import qualified Network.Socket.ByteString as Network
@@ -28,13 +34,32 @@
     , backendSend :: ByteString -> IO ()
     -- ^ Send a bytestring through the connection.
     , backendRecv :: Int -> IO ByteString
-    -- ^ Receive specified number of bytes from the connection.
+    -- ^ Receive the specified number of bytes from the connection.
+    -- Fewer bytes are returned only at the end of the stream.
     }
 
+-- | Types which a 'Network.TLS.Context' can be created on.
 class HasBackend a where
+    -- | Prepare the connection before use.
     initializeBackend :: a -> IO ()
+
+    -- | The IO functions of the connection.
     getBackend :: a -> Backend
 
+    -- | A receive which can give up.  With it, 'Network.TLS.bye' waits for the
+    --   peer's last handshake messages without interrupting a receive.
+    --
+    -- @since 2.6.0
+    getBackendRecvWith :: a -> Maybe RecvWith
+    getBackendRecvWith _ = Nothing
+
+-- | A receive of the specified number of bytes which gives up once the
+--   'STM' action succeeds, answering what it gave as 'Left'.  Bytes
+--   already received by then are answered instead.
+--
+-- @since 2.6.0
+newtype RecvWith = RecvWith (forall g. Int -> STM g -> IO (Either g ByteString))
+
 instance HasBackend Backend where
     initializeBackend _ = return ()
     getBackend = id
@@ -60,6 +85,20 @@
                 if B.null r
                     then return []
                     else (r :) <$> loop (left - B.length r)
+#if MIN_VERSION_network(3,2,12)
+    getBackendRecvWith sock = Just $ RecvWith recvAllWith
+      where
+        recvAllWith n giveUp = fmap B.concat . sequence <$> loop n
+          where
+            loop 0 = return []
+            loop left = do
+                r <- Network.recvWith sock left giveUp
+                case r of
+                    Left g -> return [Left g]
+                    Right bs
+                        | B.null bs -> return []
+                        | otherwise -> (Right bs :) <$> loop (left - B.length bs)
+#endif
 
 instance HasBackend Handle where
     initializeBackend handle = hSetBuffering handle NoBuffering
diff --git a/Network/TLS/Context.hs b/Network/TLS/Context.hs
--- a/Network/TLS/Context.hs
+++ b/Network/TLS/Context.hs
@@ -147,7 +147,7 @@
     doRequestCertificateAsync = requestCertificateAsyncServer
     doPostHandshakeAuthWith = \_ _ _ -> return ()
 
--- | create a new context using the backend and parameters specified.
+-- | Create a new context using the backend and parameters specified.
 contextNew
     :: (MonadIO m, HasBackend backend, TLSParams params)
     => backend
@@ -201,6 +201,7 @@
     let ctx =
             Context
                 { ctxBackend = getBackend backend
+                , ctxBackendRecvWith = getBackendRecvWith backend
                 , ctxShared = shared
                 , ctxSupported = supported
                 , ctxDebug = debug
@@ -272,7 +273,7 @@
 
 -- | Getting the "tls-unique" channel binding for TLS 1.2 (RFC5929).
 --   For TLS 1.3, 'Nothing' is returned.
---   'supportedExtendedMainSecret' must be 'RequireEMS'
+--   'supportedExtendedMainSecret' must be 'RequireEMS'.
 --   But in general, it is highly recommended to upgrade to TLS 1.3
 --   and use the "tls-exporter" channel binding via 'getTLSExporter'.
 getTLSUnique :: Context -> IO (Maybe ByteString)
diff --git a/Network/TLS/Context/Internal.hs b/Network/TLS/Context/Internal.hs
--- a/Network/TLS/Context/Internal.hs
+++ b/Network/TLS/Context/Internal.hs
@@ -121,13 +121,15 @@
 import Network.TLS.Util
 import Network.TLS.X509 (CertificateChain)
 
--- | A TLS Context keep tls specific state, parameters and backend information.
+-- | A TLS Context keeps TLS specific state, parameters and backend information.
 data Context
     = forall a.
       Monoid a =>
     Context
     { ctxBackend :: Backend
     -- ^ return the backend object associated with this context
+    , ctxBackendRecvWith :: Maybe RecvWith
+    -- ^ 'getBackendRecvWith' of the backend
     , ctxSupported :: Supported
     , ctxShared :: Shared
     , ctxDebug :: DebugParams
@@ -319,8 +321,8 @@
 
 data Established
     = NotEstablished
-    | EarlyDataAllowed Int -- server: remaining 0-RTT bytes allowed
-    | EarlyDataNotAllowed Int -- server: remaining 0-RTT bytes allowed to skip
+    | EarlyDataAllowed Word32 -- server: remaining 0-RTT bytes allowed
+    | EarlyDataNotAllowed Word32 -- server: remaining 0-RTT bytes allowed to skip
     | EarlyDataSending
     | Established
     deriving (Eq, Show)
@@ -463,7 +465,7 @@
         _ -> return False
   where
     -- The AEAD tag and the inner content type are not early data.
-    cost = max 1 (len - 17)
+    cost = fromIntegral $ max 1 (len - 17)
 
 withLog :: Context -> (Logging -> IO ()) -> IO ()
 withLog ctx f = ctxWithHooks ctx (f . hookLogging)
diff --git a/Network/TLS/Core.hs b/Network/TLS/Core.hs
--- a/Network/TLS/Core.hs
+++ b/Network/TLS/Core.hs
@@ -1,6 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE RecordWildCards #-}
 {-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeApplications #-}
 {-# OPTIONS_HADDOCK hide #-}
 
 module Network.TLS.Core (
@@ -31,15 +32,15 @@
 ) where
 
 import Control.Concurrent (forkIO)
-import Control.Concurrent.MVar
+import Control.Concurrent.STM
 import qualified Control.Exception as E
 import Control.Monad.State.Strict
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Char8 as C8
 import qualified Data.ByteString.Lazy as L
 import Data.IORef
-import System.Timeout
 
+import Network.TLS.Backend (Backend (..), RecvWith (..))
 import Network.TLS.Context
 import Network.TLS.Context.Internal (
     PHAResult (..),
@@ -71,9 +72,9 @@
  )
 import Network.TLS.Util (catchException, mapChunks_)
 
--- | Handshake for a new TLS connection
+-- | Handshake for a new TLS connection.
 -- This is to be called at the beginning of a connection, and during renegotiation.
--- Don't use this function as the acquire resource of 'bracket'.
+-- Don't use this function as the acquire resource of 'Control.Exception.bracket'.
 handshake :: MonadIO m => Context -> m ()
 handshake ctx = do
     handshake_ ctx
@@ -97,7 +98,7 @@
             -- it the only reader and makes the next receive wait for it to
             -- finish; its outcome is left in 'tls13stPendingRecv' for that
             -- receive to pick up.
-            done <- newEmptyMVar
+            done <- newEmptyTMVarIO
             void $ forkIO $ withReadLock ctx $ do
                 r <- E.try $ recvData13 ctx
                 modifyTLS13State ctx $ \st ->
@@ -106,8 +107,11 @@
                             Right dat -> PendingRecvData dat
                             Left err -> PendingRecvError err
                         }
-                putMVar done ()
-            arrived <- timeout rtt $ takeMVar done
+                atomically $ putTMVar done ()
+            late <- registerDelay rtt
+            arrived <-
+                atomically $
+                    (Just <$> takeTMVar done) `orElse` (Nothing <$ (readTVar late >>= check))
             -- Still report the authentication failure from 'handshake' itself
             -- whenever it did arrive in time.
             when (isJust arrived) $ do
@@ -127,19 +131,18 @@
     let rtt' = max (fromIntegral rtt) 10
     return (rtt' * rttFactor * 1000) -- ms to us
 
--- | Notify the context that this side wants to close connection.
--- This is important that it is called before closing the handle, otherwise
--- the session might not be resumable (for version < TLS1.2).
--- This doesn't actually close the handle.
+-- | Notify the peer that this side wants to close the connection, by
+-- sending close_notify.  It should be called before closing the backend.
+-- This doesn't actually close the backend.
 --
 -- Proper usage is as follows:
 --
 -- > ctx <- contextNew <backend> <params>
 -- > handshake ctx
 -- > ...
--- > bye
+-- > bye ctx
 --
--- The following code ensures nothing but is no harm.
+-- The following code guarantees nothing more, but does no harm.
 --
 -- > bracket (contextNew <backend> <params>) bye $ \ctx -> do
 -- >   handshake ctx
@@ -186,10 +189,24 @@
     -- abandon the receive.  Abandoning it can stop the connection part way
     -- through a record, after which nothing can be read from it again -- which
     -- is acceptable only because we are closing the connection here anyway.
+    --
+    -- A backend which can give up on a receive does so after 'rtt'; with
+    -- one which cannot, the messages are not waited for at all.
     tryRecvHS13 :: Int -> IO Bool -> IO ()
-    tryRecvHS13 rtt chk =
-        void $ tryWithReadLock ctx $ timeout rtt $ recvHS13 ctx chk
+    tryRecvHS13 rtt chk = case ctxBackendRecvWith ctx of
+        Nothing -> return ()
+        Just (RecvWith recvWith) -> do
+            late <- registerDelay rtt
+            let giveUp = readTVar late >>= check
+                recv n = recvWith n giveUp >>= either (\() -> E.throwIO GaveUpRecv) return
+                ctx' = ctx{ctxBackend = (ctxBackend ctx){backendRecv = recv}}
+            void $ tryWithReadLock ctx $ E.try @GaveUpRecv $ recvHS13 ctx' chk
 
+-- | Thrown by a receive in 'bye' which has given up, and caught there.
+data GaveUpRecv = GaveUpRecv deriving (Show)
+
+instance E.Exception GaveUpRecv
+
 bye_ :: MonadIO m => Context -> m ()
 bye_ ctx = liftIO $ do
     -- Although setEOF is always protected by the read lock, here we don't try
@@ -203,8 +220,8 @@
                 then sendPacket13 ctx $ Alert13 [(AlertLevel_Warning, CloseNotify)]
                 else sendPacket12 ctx $ Alert [(AlertLevel_Warning, CloseNotify)]
 
--- | If the ALPN extensions have been used, this will
--- return get the protocol agreed upon.
+-- | If the ALPN extension has been used, this will
+-- return the protocol agreed upon.
 getNegotiatedProtocol :: MonadIO m => Context -> m (Maybe ByteString)
 getNegotiatedProtocol ctx = liftIO $ usingState_ ctx S.getNegotiatedProtocol
 
@@ -226,8 +243,8 @@
                 sendAction ctx
                 writeIORef (ctxPendingSendAction ctx) Nothing
 
--- | sendData sends a bunch of data.
--- It will automatically chunk data to acceptable packet size
+-- | Sending a bunch of data.
+-- It will automatically chunk data to acceptable record sizes.
 sendData :: MonadIO m => Context -> L.ByteString -> m ()
 sendData _ "" = return ()
 sendData ctx dataToSend = liftIO $ do
@@ -375,7 +392,7 @@
     process (AppData13 "") = checkPHAResponse >> recvData13 ctx
     process (AppData13 x) = do
         checkPHAResponse
-        let chunkLen = C8.length x
+        let chunkLen = fromIntegral $ C8.length x
         established <- ctxEstablished ctx
         case established of
             EarlyDataAllowed maxSize
@@ -414,7 +431,7 @@
             (_, usedCipher, _, _) <- getTxRecordState ctx
             -- mMaxSize is always Just, but anyway
             let extract (EarlyDataIndication mMaxSize) =
-                    maybe 0 (fromIntegral . safeNonNegative32) mMaxSize
+                    fromMaybe 0 mMaxSize
             let choice = makeCipherChoice TLS13 usedCipher
                 psk = derivePSK choice resumptionSecret nonce
                 maxSize =
@@ -528,7 +545,7 @@
                         MsgTNewSessionTicket
                         exts
                         0
-                        (\(EarlyDataIndication mms) -> fromIntegral $ safeNonNegative32 $ fromJust mms)
+                        (\(EarlyDataIndication mms) -> fromJust mms)
                 life7d = min life 604800 -- 7 days max
             tinfo <- createTLS13TicketInfo life7d (Right add) Nothing
             sdata <- getSessionData13 ctx usedCipher tinfo maxSize psk
@@ -648,6 +665,6 @@
 
 {-# DEPRECATED recvData' "use recvData that returns strict bytestring" #-}
 
--- | same as recvData but returns a lazy bytestring.
+-- | Same as 'recvData' but returns a lazy bytestring.
 recvData' :: MonadIO m => Context -> m L.ByteString
 recvData' ctx = L.fromChunks . (: []) <$> recvData ctx
diff --git a/Network/TLS/Extra/FFDHE.hs b/Network/TLS/Extra/FFDHE.hs
--- a/Network/TLS/Extra/FFDHE.hs
+++ b/Network/TLS/Extra/FFDHE.hs
@@ -1,5 +1,5 @@
 -- |
--- Module      : Network.TLS.Extra
+-- Module      : Network.TLS.Extra.FFDHE
 -- License     : BSD-style
 -- Maintainer  : Kazu Yamamoto <kazu@iij.ad.jp>
 -- Stability   : experimental
diff --git a/Network/TLS/Handshake/Common13.hs b/Network/TLS/Handshake/Common13.hs
--- a/Network/TLS/Handshake/Common13.hs
+++ b/Network/TLS/Handshake/Common13.hs
@@ -24,7 +24,6 @@
     getCurrentTimeFromBase,
     getSessionData13,
     isHashSignatureValid13,
-    safeNonNegative32,
     RecvHandshake13M,
     runRecvHandshake13,
     recvHandshake13,
@@ -363,7 +362,7 @@
 ----------------------------------------------------------------
 
 getSessionData13
-    :: Context -> Cipher -> TLS13TicketInfo -> Int -> ByteString -> IO SessionData
+    :: Context -> Cipher -> TLS13TicketInfo -> Word32 -> ByteString -> IO SessionData
 getSessionData13 ctx usedCipher tinfo maxSize psk = do
     ver <- usingState_ ctx getVersion
     malpn <- usingState_ ctx getNegotiatedProtocol
@@ -385,18 +384,6 @@
             , sessionClientCertificate = clientCert
             , sessionAppData = Nothing
             }
-
-----------------------------------------------------------------
-
--- Word32 is used in TLS 1.3 protocol.
--- Int is used for API for Haskell TLS because it is natural.
--- If Int is 64 bits, users can specify bigger number than Word32.
--- If Int is 32 bits, 2^31 or larger may be converted into minus numbers.
-safeNonNegative32 :: (Num a, Ord a, FiniteBits a) => a -> a
-safeNonNegative32 x
-    | x <= 0 = 0
-    | finiteBitSize x <= 32 = x
-    | otherwise = x `min` fromIntegral (maxBound :: Word32)
 
 ----------------------------------------------------------------
 
diff --git a/Network/TLS/Handshake/Server/ServerHello13.hs b/Network/TLS/Handshake/Server/ServerHello13.hs
--- a/Network/TLS/Handshake/Server/ServerHello13.hs
+++ b/Network/TLS/Handshake/Server/ServerHello13.hs
@@ -156,7 +156,7 @@
             False
             (\PostHandshakeAuth -> True)
 
-    rtt0max = safeNonNegative32 $ serverEarlyDataSize sparams
+    rtt0max = serverEarlyDataSize sparams
     rtt0accept = serverEarlyDataSize sparams > 0
 
     decideCredentialInfo allCreds = do
diff --git a/Network/TLS/Handshake/Server/TLS13.hs b/Network/TLS/Handshake/Server/TLS13.hs
--- a/Network/TLS/Handshake/Server/TLS13.hs
+++ b/Network/TLS/Handshake/Server/TLS13.hs
@@ -156,7 +156,7 @@
     sendPacket13 ctx $ Handshake13 [nst] []
   where
     choice = makeCipherChoice TLS13 usedCipher
-    rtt0max = safeNonNegative32 $ serverEarlyDataSize sparams
+    rtt0max = serverEarlyDataSize sparams
     sendNST = PSK_DHE_KE `elem` dhModes
 
     dhModes = case extensionLookup EID_PskKeyExchangeModes exts
@@ -180,7 +180,7 @@
             | maxSize == 0 = []
             | otherwise = [earlyDataExt]
           where
-            earlyDataExt = toExtensionRaw $ EarlyDataIndication $ Just $ fromIntegral maxSize
+            earlyDataExt = toExtensionRaw $ EarlyDataIndication $ Just maxSize
     adjustLifetime i
         | i < 0 = 0
         | i > 604800 = 604800
diff --git a/Network/TLS/Parameters.hs b/Network/TLS/Parameters.hs
--- a/Network/TLS/Parameters.hs
+++ b/Network/TLS/Parameters.hs
@@ -60,14 +60,14 @@
 -- | All settings should not be used in production
 data DebugParams = DebugParams
     { debugSeed :: Maybe Seed
-    -- ^ Disable the true randomness in favor of deterministic seed that will produce
-    -- a deterministic random from. This is useful for tests and debugging purpose.
-    -- Do not use in production
+    -- ^ Disable the true randomness in favor of a deterministic seed,
+    -- from which deterministic random values are produced.  This is
+    -- useful for tests and debugging.  Do not use in production.
     --
     -- Default: 'Nothing'
     , debugPrintSeed :: Seed -> IO ()
-    -- ^ Add a way to print the seed that was randomly generated. reusing the same seed
-    -- will reproduce the same randomness with 'debugSeed'
+    -- ^ Add a way to print the seed that was randomly generated.  Reusing
+    -- the same seed with 'debugSeed' will reproduce the same randomness.
     --
     -- Default: no printing
     , debugVersionForced :: Maybe Version
@@ -79,7 +79,14 @@
     --
     -- Default: no printing
     , debugError :: String -> IO ()
+    -- ^ Printing errors which terminate the connection.  A rejected
+    -- certificate chain is printed in PEM.
+    --
+    -- Default: no printing
     , debugTraceKey :: String -> IO ()
+    -- ^ Printing transcript hashes for tracing the key schedule.
+    --
+    -- Default: no printing
     }
 
 {-# NOINLINE keyLogLock #-}
@@ -117,13 +124,13 @@
 
 data ClientParams = ClientParams
     { clientUseMaxFragmentLength :: Maybe MaxFragmentEnum
-    -- ^
+    -- ^ Not used any more.  Use 'limitRecordSize' instead.
     --
     -- Default: 'Nothing'
     , clientServerIdentification :: (HostName, ByteString)
     -- ^ Define the name of the server, along with an extra service
-    -- identification blob.  this is important that the hostname part
-    -- is properly filled for security reason, as it allow to properly
+    -- identification blob.  It is important that the hostname part
+    -- is properly filled for security reasons, as it allows to properly
     -- associate the remote side with the given certificate during a
     -- handshake.
     --
@@ -135,25 +142,25 @@
     -- This value is typically set by 'defaultParamsClient'.
     , clientUseServerNameIndication :: Bool
     -- ^ Allow the use of the Server Name Indication TLS extension
-    -- during handshake, which allow the client to specify which host
-    -- name, it's trying to access. This is useful to distinguish
+    -- during handshake, which allows the client to specify which host
+    -- name it's trying to access. This is useful to distinguish
     -- CNAME aliasing (e.g. web virtual host).
     --
     -- Default: 'True'
     , clientWantSessionResume :: Maybe (SessionID, SessionData)
-    -- ^ try to establish a connection using this session for TLS
+    -- ^ Try to establish a connection using this session for TLS
     -- 1.2/TLS 1.3.  This can be used for TLS 1.3 but for backward
-    -- compatibility purpose only.  Use 'clientWantSessionResume13'
+    -- compatibility purpose only.  Use 'clientWantSessionResumeList'
     -- instead for TLS 1.3.
     --
     -- Default: 'Nothing'
     , clientWantSessionResumeList :: [(SessionID, SessionData)]
-    -- ^ try to establish a connection using one of this sessions
-    -- especially for TLS 1.3.  This take precedence over
+    -- ^ Try to establish a connection using one of these sessions
+    -- especially for TLS 1.3.  This takes precedence over
     -- 'clientWantSessionResume'.  For convenience, this can be
     -- specified for TLS 1.2 but only the first entry is used.
     --
-    -- Default: '[]'
+    -- Default: @[]@
     , clientWantTicket :: Bool
     -- ^ Whether to solicit TLS 1.2 session tickets (or TLS 1.3
     -- resumption PSKs) from servers.  With a 'False' setting,
@@ -169,14 +176,11 @@
     , clientHooks :: ClientHooks
     -- ^ See the default value of 'ClientHooks'.
     , clientSupported :: Supported
-    -- ^ In this element, you'll need to override the default empty
-    -- value of of 'supportedCiphers' with a suitable cipherlist.
-    --
-    -- See the default value of 'Supported'.
+    -- ^ See the default value of 'Supported'.
     , clientDebug :: DebugParams
     -- ^ See the default value of 'DebugParams'.
     , clientUseEarlyData :: Bool
-    -- ^ Client tries to send early data in TLS 1.3 via 'sendData' if
+    -- ^ Client tries to send early data in TLS 1.3 via 'Network.TLS.sendData' if
     -- possible.  If not accepted by the server, the early data is
     -- automatically re-sent.
     --
@@ -218,13 +222,12 @@
     --
     -- Default: 'False'
     , serverCACertificates :: [SignedCertificate]
-    -- ^ This is a list of certificates from which the disinguished
-    -- names are sent in certificate request messages.  For TLS1.0, it
-    -- should not be empty.
+    -- ^ This is a list of certificates from which the distinguished
+    -- names are sent in certificate request messages.
     --
-    -- Default: '[]'
+    -- Default: @[]@
     , serverDHEParams :: Maybe DHParams
-    -- ^ Server Optional Diffie Hellman parameters.  Setting
+    -- ^ Server optional Diffie-Hellman parameters.  Setting
     -- parameters is necessary for FFDHE key exchange when clients are
     -- not compatible with RFC 7919.
     --
@@ -241,9 +244,9 @@
     -- ^ See the default value of 'Supported'.
     , serverDebug :: DebugParams
     -- ^ See the default value of 'DebugParams'.
-    , serverEarlyDataSize :: Int
-    -- ^ Server accepts this size of early data in TLS 1.3.  0 (or
-    -- lower) means that the server does not accept early data.
+    , serverEarlyDataSize :: Word32
+    -- ^ Server accepts this size of early data in TLS 1.3.  0 means
+    -- that the server does not accept early data.
     --
     -- Early data can be replayed.  The server is to accept 0-RTT for the
     -- same handshake at most once (RFC 9846 Section 8), which is left to
@@ -259,7 +262,7 @@
     , serverECHKey :: [(ConfigId, ByteString)]
     -- ^ ECH secret keys.
     --
-    -- Default: '[]'
+    -- Default: @[]@
     --
     -- @since 2.1.9
     }
@@ -296,12 +299,9 @@
     --
     -- Default: @[TLS13,TLS12]@
     , supportedCiphers :: [Cipher]
-    -- ^ Supported cipher methods.  The default is empty, specify a
-    -- suitable cipher list.
-    -- 'Network.TLS.Extra.Cipher.ciphersuite_default' is often a good
-    -- choice.
+    -- ^ Supported cipher methods.
     --
-    -- Default: @[]@
+    -- Default: 'Network.TLS.Extra.Cipher.ciphersuite_default'
     , supportedMinRSAKeySize :: Int
     -- ^ The least size in bits of the RSA key in the peer's leaf
     -- certificate.  A shorter one is refused with bad_certificate; 0 lets
@@ -352,16 +352,14 @@
     --
     -- Default: @[nullCompression]@
     , supportedHashSignatures :: [SignatureScheme]
-    -- ^ All supported hash/signature algorithms pair for client
+    -- ^ All supported signature schemes for client
     -- certificate verification and server signature in (EC)DHE,
     -- ordered by decreasing priority.
     --
     -- This list is sent to the peer as part of the
     -- "signature_algorithms" extension.  It is used to restrict
     -- accepted signatures received from the peer at TLS level (not in
-    -- X.509 certificates), but only when the TLS version is 1.2 or
-    -- above.  In order to disable SHA-1 one must then also disable
-    -- earlier protocol versions in 'supportedVersions'.
+    -- X.509 certificates).
     --
     -- The list also impacts the selection of possible algorithms when
     -- generating signatures.
@@ -386,7 +384,7 @@
     --   Default: 'False'
     , supportedExtendedMainSecret :: EMSMode
     -- ^ The mode regarding extended main secret.  Enabling this
-    -- extension provides better security for TLS versions 1.2.  TLS
+    -- extension provides better security for TLS 1.2.  TLS
     -- 1.3 provides the security properties natively and does not need
     -- the extension.
     --
@@ -405,19 +403,16 @@
     --
     --   Default: 'True'
     , supportedEmptyPacket :: Bool
-    -- ^ In ver <= TLS1.0, block ciphers using CBC are using CBC
-    -- residue as IV, which can be guessed by an attacker. Hence, an
-    -- empty packet is normally sent before a normal data packet, to
-    -- prevent guessability. Some Microsoft TLS-based protocol
-    -- implementations, however, consider these empty packets as a
-    -- protocol violation and disconnect. If this parameter is
-    -- 'False', empty packets will never be added, which is less
-    -- secure, but might help in rare cases.
+    -- ^ A workaround for CBC in TLS 1.0.  Not used any more since TLS
+    -- 1.0 is not supported.
     --
     --   Default: 'True'
     , supportedHPKE :: [(KEM_ID, KDF_ID, AEAD_ID)]
-    -- ^ Client only.
+    -- ^ Client only.  HPKE cipher suites for ECH in preferred order.
     --
+    -- Default: X25519 and P-256 with AES-128-GCM or ChaCha20-Poly1305,
+    -- and P-521 with AES-256-GCM
+    --
     -- @since 2.1.9
     , supportedGroups :: [Group]
     -- ^ A list of supported elliptic curves and finite-field groups
@@ -551,10 +546,14 @@
     , sharedECHConfigList :: ECHConfigList
     -- ^ ECH configuration.
     --
+    -- Default: @[]@
+    --
     -- @since 2.1.9
     , sharedLimit :: Limit
     -- ^ Limitation parameters.
     --
+    -- See the default value of 'Limit'.
+    --
     -- @since 2.1.8
     }
 
@@ -620,7 +619,7 @@
 -- | A set of callbacks run by the clients for various corners of TLS establishment
 data ClientHooks = ClientHooks
     { onCertificateRequest :: OnCertificateRequest
-    -- ^ This action is called when the a certificate request is
+    -- ^ This action is called when a certificate request is
     -- received from the server. The callback argument is the
     -- information from the request.  The server, at its discretion,
     -- may be willing to continue the handshake without a client
@@ -643,7 +642,7 @@
     --
     -- Each certificate except the last should be signed by the
     -- following one.  The returned private key must be for the first
-    -- certificates in the chain.  This key will be used to signing
+    -- certificate in the chain.  This key will be used for signing
     -- the certificate verify message.
     --
     -- The public key in the first certificate, and the matching
@@ -664,7 +663,7 @@
     -- hint, since TLS 1.3 servers will generally list the RSASSA-PSS
     -- schemes, whose first octet is @0x08@.
     --
-    -- Note that is is the responsibility of this action to select a
+    -- Note that it is the responsibility of this action to select a
     -- certificate matching one of the requested certificate types
     -- (public key algorithms).  Returning a non-matching one will
     -- lead to handshake failure later.
@@ -693,7 +692,7 @@
     -- Default: 'validateDefault'
     , onSuggestALPN :: IO (Maybe [ByteString])
     -- ^ This action is called when the client sends ClientHello
-    --   to determine ALPN values such as '["h2", "http/1.1"]'.
+    --   to determine ALPN values such as @["h2", "http/1.1"]@.
     --
     -- Default: returns 'Nothing'
     , onCustomFFDHEGroup :: DHParams -> DHPublic -> IO GroupUsage
@@ -704,19 +703,21 @@
     --
     --   With TLS 1.3 custom groups have been removed from the
     --   protocol, so this callback is only used when the version
-    --   negotiated is 1.2 or below.
+    --   negotiated is 1.2.
     --
-    --   The default behavior with (dh_p, dh_g, dh_size) and pub as
+    --   The default behavior with (dh_p, dh_g, dh_size) and pub is as
     --   follows:
     --
     --   (1) rejecting if dh_p is even
     --   (2) rejecting unless 1 < dh_g && dh_g < dh_p - 1
-    --   (3) rejecting unless 1 < dh_p && pub < dh_p - 1
+    --   (3) rejecting unless 1 < pub && pub < dh_p - 1
     --   (4) rejecting if dh_size < 1024 (to prevent Logjam attack)
     --
     --   See RFC 7919 section 3.1 for recommendations.
     , onServerFinished :: Information -> IO ()
-    -- ^ When a handshake is done, this hook can check `Information`.
+    -- ^ When a handshake is done, this hook can check 'Information'.
+    --
+    -- Default: does nothing
     , onSelectKeyShareGroups :: [Group] -> [Group]
     -- ^ A function to select groups in "key_share" by TLS 1.3 client.
     --
@@ -727,19 +728,20 @@
     --   The default function specifies a pair of hybrid (classical +
     --   post quantum) group and classical group to transit from
     --   classical key exchange to hybrid key exchange. With the
-    --   default value of 'supportedGroups', X25519MLKEM and X25519
+    --   default value of 'supportedGroups', X25519MLKEM768 and X25519
     --   are chosen.
     --
     --   Middleboxes may drop a ClientHello that contains large
-    --   X2219MLKEM. In such environment, @take 1@, which selects
-    --   X22519 only with the default value, is maybe a good
-    --   candidate.
+    --   X25519MLKEM768. In such environment, @filter (== X25519)@,
+    --   which selects X25519 only, is maybe a good candidate.
     --
-    --   In the case where X22519 is only contained in "key_share", a
-    --   wise-server without nasty middleboxes may ask the client to
-    --   send X2219MLKEM via HelloRetryRequest as X2219MLKEM is
+    --   In the case where X25519 is only contained in "key_share", a
+    --   wise server without nasty middleboxes may ask the client to
+    --   send X25519MLKEM768 via HelloRetryRequest as X25519MLKEM768 is
     --   specified in "supported_groups".
     --
+    --   Default: the first hybrid group and the first other group
+    --
     --   @since 2.2.3
     }
 
@@ -775,7 +777,7 @@
     { onClientCertificate :: CertificateChain -> IO CertificateUsage
     -- ^ This action is called when a client certificate chain is
     -- received from the client.  When it returns a
-    -- CertificateUsageReject value, the handshake is aborted.
+    -- 'CertificateUsageReject' value, the handshake is aborted.
     --
     -- The function is not expected to verify the key-usage extension
     -- of the certificate.  This verification is performed by the
@@ -793,13 +795,12 @@
     --
     -- Default: returns 'False'
     , onCipherChoosing :: Version -> [Cipher] -> Cipher
-    -- ^ Allow the server to choose the cipher relative to the the
-    -- client version and the client list of ciphers.
-    --
-    -- This could be useful with old clients and as a workaround to
-    -- the BEAST (where RC4 is sometimes preferred with TLS < 1.1)
+    -- ^ Allow the server to choose the cipher relative to the
+    -- negotiated version and the ciphers in common with the client.
+    -- They are in the order of 'supportedCiphers', or in the client's
+    -- order with 'supportedClientCipherOrder'.
     --
-    -- The client cipher list cannot be empty.
+    -- The list is never empty, and the result must be one of it.
     --
     -- Default: taking the head of ciphers.
     , onServerNameIndication :: Maybe HostName -> IO Credentials
@@ -816,14 +817,14 @@
     -- Default: returns 'mempty'
     , onNewHandshake :: Measurement -> IO Bool
     -- ^ At each new handshake, we call this hook to see if we allow
-    -- handshake to happens.
+    -- the handshake to happen.
     --
     -- Default: returns 'True'
     , onALPNClientSuggest :: Maybe ([ByteString] -> IO ByteString)
     -- ^ Allow the server to choose an application layer protocol
     --   suggested from the client through the ALPN (Application Layer
-    --   Protocol Negotiation) extensions.  If the server supports no
-    --   protocols that the client advertises an empty 'ByteString'
+    --   Protocol Negotiation) extension.  If the server supports no
+    --   protocols that the client advertises, an empty 'ByteString'
     --   should be returned.
     --
     -- Default: 'Nothing'
@@ -840,8 +841,8 @@
     -- ^ A function to select one key share by TLS 1.3 server.
     --
     -- The 1st argument is server's 'supportedGroupsTLS13'.
-    -- The 2nd arguments is client's groups in "supported_groups"
-    -- The 3rd arguments is client's groups in "key_share".
+    -- The 2nd argument is client's groups in "supported_groups".
+    -- The 3rd argument is client's groups in "key_share".
     --
     -- 'True' in the result indicates sending a hello retry request
     -- with this group.
@@ -909,17 +910,29 @@
 -- | Information related to a running context, e.g. current cipher
 data Information = Information
     { infoVersion :: Version
+    -- ^ The negotiated version.
     , infoCipher :: Cipher
+    -- ^ The negotiated cipher.
     , infoCompression :: Compression
+    -- ^ The negotiated compression.
     , infoMainSecret :: Maybe ByteString
+    -- ^ The main secret of TLS 1.2.
     , infoExtendedMainSecret :: Bool
+    -- ^ Whether the extended main secret is used in TLS 1.2.
     , infoClientRandom :: Maybe ClientRandom
+    -- ^ The random of ClientHello.
     , infoServerRandom :: Maybe ServerRandom
+    -- ^ The random of ServerHello.
     , infoSupportedGroup :: Maybe Group
+    -- ^ The group used for the key exchange.
     , infoTLS12Resumption :: Bool
+    -- ^ Whether the TLS 1.2 session was resumed.
     , infoTLS13HandshakeMode :: Maybe HandshakeMode13
+    -- ^ The handshake mode of TLS 1.3.
     , infoIsEarlyDataAccepted :: Bool
+    -- ^ Whether the early data of TLS 1.3 was accepted.
     , infoIsECHAccepted :: Bool
+    -- ^ Whether Encrypted Client Hello was accepted.
     , infoServerSignatureScheme :: Maybe SignatureScheme
     -- ^ The scheme of the server's signature: ServerKeyExchange in TLS 1.2,
     -- CertificateVerify in TLS 1.3.  'Nothing' on resumption.
@@ -944,7 +957,7 @@
     -- extension. When negotiated, both my limit and peer's limit are
     -- enabled for protected communication.
     --
-    -- Default: Nothing
+    -- Default: 'Nothing'
     , limitHandshakeFragment :: Int
     -- ^ The number of records that may carry a handshake message before
     -- the one that completes it.  A peer may split a message into records
@@ -955,7 +968,7 @@
     -- ^ Maximum number of consecutive TLS 1.3 KeyUpdate messages accepted
     -- without intervening non-empty application data.  This bounds the CPU
     -- work and response amplification a peer can trigger while application
-    -- code is blocked inside 'recvData'.  'Nothing' and non-positive values
+    -- code is blocked inside 'Network.TLS.recvData'.  'Nothing' and non-positive values
     -- disable the limit; they do not disable KeyUpdate processing.
     --
     -- Default: @Just 32@
diff --git a/Network/TLS/PostHandshake.hs b/Network/TLS/PostHandshake.hs
--- a/Network/TLS/PostHandshake.hs
+++ b/Network/TLS/PostHandshake.hs
@@ -23,7 +23,7 @@
 -- exception is thrown if the authentication fails. Server only.
 --
 -- This reads the client's response by itself, so it must not be called
--- while another thread is in 'recvData', and application data received
+-- while another thread is in 'Network.TLS.recvData', and application data received
 -- before the response closes the connection, against RFC 9846 Section 4.7.2.
 {-# DEPRECATED
     requestCertificate
@@ -34,11 +34,11 @@
     checkValid ctx >> doRequestCertificate_ (ctxRoleParams ctx) ctx
 
 -- | Post-handshake certificate request with TLS 1.3, without waiting for
--- the response.  The response is processed by 'recvData', so another
+-- the response.  The response is processed by 'Network.TLS.recvData', so another
 -- thread or the caller itself must keep calling it.  The returned action
 -- gives the result; with 'True' it blocks until the result is known, with
 -- 'False' it returns 'PHAPending' meanwhile.  Only one request may be
--- pending.  'getClientCertificateChain' gives the authenticated chain.
+-- pending.  'Network.TLS.getClientCertificateChain' gives the authenticated chain.
 -- Server only.
 requestCertificateAsync :: Context -> IO (Bool -> IO PHAResult)
 requestCertificateAsync ctx =
diff --git a/Network/TLS/QUIC.hs b/Network/TLS/QUIC.hs
--- a/Network/TLS/QUIC.hs
+++ b/Network/TLS/QUIC.hs
@@ -152,7 +152,7 @@
     , quicDone :: Context -> IO ()
     -- ^ Called when 'handshake' is done. 'tlsQUICServer' is
     -- finished after calling this hook. 'tlsQUICClient' calls
-    -- 'recvData' after calling this hook to wait for new session
+    -- 'Network.TLS.recvData' after calling this hook to wait for new session
     -- tickets.
     }
 
@@ -261,5 +261,5 @@
         }
 
 -- | Max early data size for QUIC.
-quicMaxEarlyDataSize :: Int
+quicMaxEarlyDataSize :: Word32
 quicMaxEarlyDataSize = 0xffffffff
diff --git a/Network/TLS/Session.hs b/Network/TLS/Session.hs
--- a/Network/TLS/Session.hs
+++ b/Network/TLS/Session.hs
@@ -17,7 +17,7 @@
     , sessionEstablish :: SessionIDorTicket -> SessionData -> IO (Maybe Ticket)
     -- ^ Used on TLS 1.2\/1.3 servers to store 'SessionData' with 'SessionID' or to encrypt 'SessionData' to get 'Ticket' ignoring 'SessionID'. Used on TLS 1.2\/1.3 clients to store 'SessionData' with 'SessionIDorTicket' and then return 'Nothing'. For clients, only this field should be set with 'noSessionManager'.
     , sessionInvalidate :: SessionIDorTicket -> IO ()
-    -- ^ Used TLS 1.2 servers to delete 'SessionData' with 'SessionID' on errors.
+    -- ^ Used on TLS 1.2 servers to delete 'SessionData' with 'SessionID' on errors.
     , sessionUseTicket :: Bool
     -- ^ Used on TLS 1.2 servers to decide to use 'SessionID' or 'Ticket'. Note that 'SessionID' and 'Ticket' are integrated as identity in TLS 1.3.
     }
diff --git a/Network/TLS/Types/Session.hs b/Network/TLS/Types/Session.hs
--- a/Network/TLS/Types/Session.hs
+++ b/Network/TLS/Types/Session.hs
@@ -44,7 +44,7 @@
     , sessionGroup :: Maybe Group
     , sessionTicketInfo :: Maybe TLS13TicketInfo
     , sessionALPN :: Maybe ByteString
-    , sessionMaxEarlyDataSize :: Int
+    , sessionMaxEarlyDataSize :: Word32
     , sessionFlags :: [SessionFlag]
     , sessionClientCertificate :: Maybe ByteString
     -- ^ On a server, the DER of the leaf certificate the client was
@@ -52,7 +52,7 @@
     , sessionAppData :: Maybe ByteString
     -- ^ Data of the application's own, kept with the session and given
     -- back on resumption; never set by this library.  A server can put
-    -- what 0-RTT depends on here and check it in 'onAccept0RTT'.
+    -- what 0-RTT depends on here and check it in 'Network.TLS.onAccept0RTT'.
     --
     -- @since 2.5.1
     }
diff --git a/Network/TLS/X509.hs b/Network/TLS/X509.hs
--- a/Network/TLS/X509.hs
+++ b/Network/TLS/X509.hs
@@ -40,7 +40,7 @@
     | CertificateRejectOther String
     deriving (Show, Eq)
 
--- | Certificate Usage callback possible returns values.
+-- | Certificate usage callback possible return values.
 data CertificateUsage
     = -- | usage of certificate accepted
       CertificateUsageAccept
@@ -62,9 +62,9 @@
 pubkeyType = show . pubkeyToAlg
 
 -- | A utility function for client authentication which can be used
--- `onClientCertificate`.
+-- as 'Network.TLS.onClientCertificate' with a store and a cache given.
 --
--- Since: 2.1.7
+-- @since 2.1.7
 validateClientCertificate
     :: CertificateStore
     -> ValidationCache
diff --git a/test/ByeSpec.hs b/test/ByeSpec.hs
new file mode 100644
--- /dev/null
+++ b/test/ByeSpec.hs
@@ -0,0 +1,92 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE CPP #-}
+
+module ByeSpec where
+
+import Control.Concurrent
+import Control.Concurrent.Async
+import Control.Concurrent.STM
+import Control.Monad (when)
+import Data.ByteString (ByteString)
+import Data.IORef
+import qualified Network.Socket as N
+import qualified Network.Socket.ByteString as NB
+import Network.TLS
+import System.Timeout
+import Test.Hspec
+import Test.QuickCheck (generate)
+
+import Arbitrary
+import PipeChan
+
+spec :: Spec
+spec = describe "bye" $ do
+    it "waits for the last handshake messages with the backend's recvWith" $ do
+        (cParams, sParams) <- generate arbitraryPairParams13
+        pipe <- newPipe
+        _ <- runPipe pipe
+        used <- newIORef False
+        let noop = return ()
+            cBackend = Backend noop noop (writePipeC pipe) (readPipeC pipe)
+            sBackend = Backend noop noop (writePipeS pipe) (readPipeS pipe)
+        cCtx <-
+            contextNew (GivingUp cBackend $ recvWithVia (readPipeC pipe) used) cParams
+        sCtx <- contextNew sBackend sParams
+        concurrently_ (handshake cCtx) (handshake sCtx)
+        -- close_notify still goes out after the receive in 'bye'.
+        timeout 5000000 (concurrently (bye cCtx) (recvData sCtx))
+            `shouldReturn` Just ((), mempty)
+        readIORef used `shouldReturn` True
+
+    it "gives up on a receive over a socket" $ do
+#if MIN_VERSION_network(3,2,12)
+        (cs, ss) <- N.socketPair N.AF_UNIX N.Stream N.defaultProtocol
+        case getBackendRecvWith cs of
+            Nothing -> expectationFailure "a socket should be able to give up"
+            Just (RecvWith recvWith) -> do
+                late <- registerDelay 50000
+                recvWith 4 (readTVar late >>= check) `shouldReturn` Left ()
+                NB.sendAll ss "abcd"
+                recvWith 4 (retry :: STM ()) `shouldReturn` Right "abcd"
+        N.close cs
+        N.close ss
+#else
+        pendingWith "needs network 3.2.12 or later"
+#endif
+
+    it "does not wait with a backend which cannot give up" $ do
+        (cParams, sParams) <- generate arbitraryPairParams13
+        pipe <- newPipe
+        _ <- runPipe pipe
+        armed <- newIORef False
+        readAfter <- newIORef False
+        let noop = return ()
+            recvC n = do
+                a <- readIORef armed
+                when a $ writeIORef readAfter True
+                readPipeC pipe n
+            cBackend = Backend noop noop (writePipeC pipe) recvC
+            sBackend = Backend noop noop (writePipeS pipe) (readPipeS pipe)
+        cCtx <- contextNew cBackend cParams
+        sCtx <- contextNew sBackend sParams
+        concurrently_ (handshake cCtx) (handshake sCtx)
+        writeIORef armed True
+        timeout 5000000 (bye cCtx) `shouldReturn` Just ()
+        readIORef readAfter `shouldReturn` False
+
+-- | A backend which can give up on a receive.
+data GivingUp = GivingUp Backend RecvWith
+
+instance HasBackend GivingUp where
+    initializeBackend _ = return ()
+    getBackend (GivingUp b _) = b
+    getBackendRecvWith (GivingUp _ f) = Just f
+
+-- | A receive given up on in STM, over a pipe which cannot be: the bytes
+--   read after giving up are lost, which closing the connection allows.
+recvWithVia :: (Int -> IO ByteString) -> IORef Bool -> RecvWith
+recvWithVia rd used = RecvWith $ \n giveUp -> do
+    writeIORef used True
+    v <- newEmptyTMVarIO
+    _ <- forkIO $ rd n >>= atomically . putTMVar v
+    atomically $ (Right <$> takeTMVar v) `orElse` (Left <$> giveUp)
diff --git a/tls.cabal b/tls.cabal
--- a/tls.cabal
+++ b/tls.cabal
@@ -1,6 +1,6 @@
 cabal-version:      2.0
 name:               tls
-version:            2.5.3
+version:            2.6.0
 license:            BSD3
 license-file:       LICENSE
 copyright:          Vincent Hanquez <vincent@snarc.org>
@@ -125,11 +125,11 @@
         bytestring >=0.10 && <0.13,
         cereal >=0.5.3 && <0.6,
         crypton >=2.1.9 && <2.3,
-        crypton-asn1-encoding >= 0.10.0 && < 0.11,
+        crypton-asn1-encoding >= 0.10.0 && < 0.12,
         crypton-asn1-types >= 0.4.1 && < 0.5,
-        crypton-x509 >=1.10 && <1.11,
+        crypton-x509 >=1.10 && <1.12,
         crypton-x509-store >=1.10 && <1.11,
-        crypton-x509-validation >=1.10 && <1.11,
+        crypton-x509-validation >=1.10 && <1.12,
         data-default,
         ech-config >=0.0.2,
         hpke >=0.4.0 && <0.5,
@@ -138,6 +138,7 @@
         ram >=0.22.0 && <0.23,
         random >=1.2 && <1.4,
         serialise >=0.2 && <0.3,
+        stm,
         transformers >=0.5 && <0.7,
         unix-time >=0.4.11 && <0.7,
         zlib >=0.7 && <0.8
@@ -163,7 +164,7 @@
         crypton-x509-system,
         ech-config,
         network,
-        network-run,
+        network-run >=0.8 && <0.9,
         tls
 
     if flag(devel)
@@ -191,7 +192,7 @@
         crypton-x509-system,
         ech-config,
         network,
-        network-run >=0.6.0 && < 0.7,
+        network-run >=0.8 && <0.9,
         tls
 
     if flag(devel)
@@ -207,6 +208,7 @@
     other-modules:
         API
         Arbitrary
+        ByeSpec
         Certificate
         ChannelBindingSpec
         CiphersSpec
@@ -235,8 +237,13 @@
         crypton-x509-validation,
         ech-config,
         hspec,
+        network,
         ram,
         serialise,
+        stm,
         time-hourglass,
         tls,
         zlib
+
+    if os(windows)
+        ghc-options: -with-rtsopts=--io-manager=native
