Skip to content

Commit cec3d3d

Browse files
committed
Add wasm32-specific patch to warn on runtimes without non-blocking stdin support
1 parent 8cc3d41 commit cec3d3d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

agda-language-server.cabal

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ library
110110
if flag(Agda-2-7-0-1)
111111
build-depends:
112112
Agda ==2.7.0.1
113+
if arch(wasm32)
114+
build-depends:
115+
unix >=2.8.0.0 && <2.9
113116

114117
executable als
115118
main-is: Main.hs

src/Server.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ import qualified Server.Handler as Handler
2828
import Switchboard (Switchboard, agdaCustomMethod)
2929
import qualified Switchboard
3030

31+
#if defined(wasm32_HOST_ARCH)
32+
import Agda.Utils.IO (catchIO)
33+
import System.IO (hPutStrLn, stderr)
34+
import System.Posix.IO (stdInput, setFdOption, FdOption (..))
35+
#endif
36+
3137
--------------------------------------------------------------------------------
3238

3339
run :: Options -> IO Int
@@ -44,6 +50,10 @@ run options = do
4450
-- Switchboard.destroy switchboard
4551
return 0
4652
Nothing -> do
53+
#if defined(wasm32_HOST_ARCH)
54+
liftIO $ setFdOption stdInput NonBlockingRead True
55+
`catchIO` (\ e -> hPutStrLn stderr $ "Failed to enable nonblocking on stdin: " ++ (show e) ++ "\nThe WASM module might not behave correctly.")
56+
#endif
4757
runServer (serverDefn options)
4858
where
4959
serverDefn :: Options -> ServerDefinition Config

0 commit comments

Comments
 (0)