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)