-
Notifications
You must be signed in to change notification settings - Fork 71
Description
If I have a Main.hs like so:
import Control.Monad.IO.Class
import Language.Javascript.JSaddle
import Language.Javascript.JSaddle.Warp
main = do
liftIO $ print 1
debug 3197 $ do
liftIO $ print 2
eval $ textToStr "document.write('3')"
liftIO $ print 4And run
$ nix-shell -p 'haskell.packages.ghc822.ghcWithPackages (p: with p; [(haskell.lib.dontCheck jsaddle-warp)])' -p haskellPackages.ghcid -j4 --run 'ghcid Main.hs -T main'
Then navigate to http://localhost:3197
On stdout, I'd hope to see:
1
<a href="http://localhost:3197">run</a>
2
4
And instead I only see
1
<a href="http://localhost:3197">run</a>
<interactive>: threadWait: invalid argument (Bad file descriptor)
If I change to
import Control.Concurrent
import Control.Monad.IO.Class
import Language.Javascript.JSaddle
import Language.Javascript.JSaddle.Warp
main = do
liftIO $ print 1
debug 3197 $ do
liftIO $ print 2
eval $ textToStr "document.write('3')"
liftIO $ print 4
threadDelay $ 1000 * 1000 * 5Then I'll see a bit more:
1
<a href="http://localhost:3197">run</a>
<interactive>: threadWait: invalid argument (Bad file descriptor)
2
4
But surely the delay is counterintuitive and shouldn't be necessary, right?
Could fixing it perhaps be as simple as having a variant of debug that doesn't forkIO inside? As GHCid issues an interrupt anyway.
Could I try such a variant easily somehow? Looking at the source here it's not immediately apparent to me how to make a non-forking variant unfortunately.
And yet another unfortunate attribute is that in a larger codebase of mine (which I am attempting to port over to use JSaddle) I can't even seem to use the threadDelay workaround. One thing or another causes ghc(i(d)) to hang on "Reloading..." when I do that. Meaning that currently, seemingly I have to choose between being able to see stdoutput during development or being able to do auto-refresh. Both of which I find rather important to have at the same time.
This I haven't been able to narrow down to such a small reproducible case as above yet, so my current hope is that if we fix the above error in general and make JSaddle.debug + ghcid + stdout work together nicely then this error will vaporize too.