haskell-servant / haskell-servant/servant
Streaming response not streaming all values
- Dominant language
- Haskell
- Stars
- 2k
- Forks
- 427
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 5
Description
Given the following server, if I connect with `curl` I only see `true`, `false`. I expect to see `true`, `false`, `true`. The logging in the program does indicate that both `False` and a second `True` are sent (using `yieldMany`).
```haskell
{-# language TypeApplications #-}
module Main where
import Servant
import Servant.Server
import RIO
import qualified Network.Wai.Handler.Warp
type API = StreamGet NewlineFraming JSON ( StreamGenerator Bool )
main :: IO ()
main = Network.Wai.Handler.Warp.run 8080 $ serve ( Proxy @API ) $ do
chan <- newTChanIO
traverse_ ( atomically . writeTChan chan ) [ True, False, True ]
return $ StreamGenerator $ \yieldFirst yieldRest -> do
atomically ( readTChan chan ) >>= yieldFirst
forever $ do
msg <- atomically ( readTChan chan )
putStrLn ( " !!!!! " <> show msg )
yieldRest msg
putStrLn "OK"
```
Contributor guide
Assessment
This issue has not been assessed yet.