Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread killed by timeout manager #850

Closed
chrisdone opened this issue Jun 18, 2021 · 0 comments
Closed

Thread killed by timeout manager #850

chrisdone opened this issue Jun 18, 2021 · 0 comments

Comments

@chrisdone
Copy link

With this file

stack runhaskell wrp.hs --resolver lts-18.0
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses,
             TemplateHaskell, OverloadedStrings #-}
import           Control.Concurrent
import qualified Text.Blaze.Html5 as H
import qualified Data.Text as T
import           Data.Text (Text)
import           Control.Monad
import           Yesod
import           Yesod.WebSockets
data Piggies = Piggies
instance Yesod Piggies
mkYesod "Piggies" [parseRoutes|
  / HomeR GET
|]
getHomeR :: Handler Html
getHomeR = do webSockets (forever (do liftIO (threadDelay (1000 * 1000))
                                      sendTextData ("Bump!" :: Text)))
              pure (H.script "// Create WebSocket connection.\n\
                             \const socket = new WebSocket('ws://localhost:3035');\n\
                             \\n\
                             \// Connection opened\n\
                             \socket.addEventListener('open', function (event) {\n\
                             \    socket.send('Hello Server!');\n\
                             \});\n\
                             \\n\
                             \// Listen for messages\n\
                             \socket.addEventListener('message', function (event) {\n\
                             \    console.log('Message from server ', event.data); socket.close()\n\
                             \});")
main = warpDebug 3035 Piggies

I see this output

$ stack runhaskell wrp.hs --resolver lts-18.0

wrp.hs:30:8: warning: [-Wdeprecations]
    In the use of ‘warpDebug’
    (imported from Yesod, but defined in Yesod.Core.Dispatch):
    Deprecated: "Please use warp instead"
   |
30 | main = warpDebug 3035 Piggies
   |        ^^^^^^^^^
18/Jun/2021:17:38:23 +0100 [Info#yesod-core] Application launched @(yesod-core-1.6.20.1-Jp7zmLxTY8gEM32OuxAOUR:Yesod.Core.Dispatch src/Yesod/Core/Dispatch.hs:175:11)
  C-c C-c
 $ stack runhaskell wrp.hs --resolver lts-18.0

wrp.hs:30:8: warning: [-Wdeprecations]
    In the use of ‘warpDebug’
    (imported from Yesod, but defined in Yesod.Core.Dispatch):
    Deprecated: "Please use warp instead"
   |
30 | main = warpDebug 3035 Piggies
   |        ^^^^^^^^^
18/Jun/2021:17:35:13 +0100 [Info#yesod-core] Application launched @(yesod-core-1.6.20.1-Jp7zmLxTY8gEM32OuxAOUR:Yesod.Core.Dispatch src/Yesod/Core/Dispatch.hs:175:11)
127.0.0.1 - - [18/Jun/2021:17:35:17 +0100] "GET / HTTP/1.1" 200 362 "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
127.0.0.1 - - [18/Jun/2021:17:35:17 +0100] "GET / HTTP/1.1" 500 - "" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
  C-c C-cwrp.hs: Thread killed by timeout manager
ghc: Thread killed by timeout manager

The two "Thread killed by timeout manager" messages appear when I hit C-c C-c. But I've elsewhere seen the message appear without shutting down the server. This is the best repro I can make so far.

Is this expected behavior? It seems to be one message for the websocket thread and one for the handler. If I omit the webSockets call, there is only one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant