Timeout doesn't work on Windows
Given the example (based on code modified from here):
import Network.HTTP.Client
import Network.HTTP.Client.Conduit (bodyReaderSource)
import Network.HTTP.Client.TLS (tlsManagerSettings)
import Network.HTTP.Types.Status (statusCode)
main :: IO ()
main = do
manager <- newManager tlsManagerSettings
request <- parseRequest "http://httpstat.us/200?sleep=10000" -- 10s
withResponse request{responseTimeout = responseTimeoutMicro 5000000 {- 5s -}} manager $ \response -> do
putStrLn $ "The status code was: " ++ show (statusCode $ responseStatus response)
This connects to a website that returns after 10s, and then runs a response with a 5s timeout. I expect it to wait 5s then fail. In actual fact, it waits 10s. Setting the timeout incredibly low (~100000 microsecs, 0.1s) does cause a timeout, so I assume the initial part of the work is preemptible, but the main part of it isn't. It also seems to often stop responding to Ctrl-C, so I'm guessing something is masked or the wrong type of safe/unsafe FFI call somewhere. Setting the timeout on the server to a ridiculous value (e.g. an hour) doesn't seem to make it abort with a timeout.
Versions: Windows 10, GHC 8.2.1, http-client 0.5.7.0.
CC @pepeiborra
This may be related to this GHC issue:
https://ghc.haskell.org/trac/ghc/ticket/8684
FWIW using race from the async package does not help to build a workaround: the withResponse call does not yield to uninterruptibleCancel. GHC issue seems likely.
Same issue with responseTimeoutMicro is in OS X, same versions of GHC/http-client.