From 59365116f3d22160633ab5ca875271178d7be58b Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Mon, 4 Jan 2016 20:25:52 +0100 Subject: [PATCH] fix MVar infinite blocking --- servant-client/src/Servant/Client/PerformRequest/GHCJS.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/servant-client/src/Servant/Client/PerformRequest/GHCJS.hs b/servant-client/src/Servant/Client/PerformRequest/GHCJS.hs index 1969c3bf..e2411fca 100644 --- a/servant-client/src/Servant/Client/PerformRequest/GHCJS.hs +++ b/servant-client/src/Servant/Client/PerformRequest/GHCJS.hs @@ -62,7 +62,9 @@ performXhr xhr request = do callback <- onReadyStateChange xhr $ do state <- readyState xhr case state of - 4 -> putMVar waiter () + 4 -> do + toPut <- isEmptyMVar waiter + when toPut (putMVar waiter ()) _ -> return () openXhr xhr (cs $ method request) (toUrl request) True setHeaders xhr (requestHeaders request)