Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.d/internal_fix-internal-error-hangs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Prevent hangs on internal errors
10 changes: 9 additions & 1 deletion src/Language/PureScript/Make.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ module Language.PureScript.Make
import Prelude.Compat

import Control.Concurrent.Lifted as C
import Control.Exception.Base (onException)
import Control.Monad hiding (sequence)
import Control.Monad.Error.Class (MonadError(..))
import Control.Monad.IO.Class
import Control.Monad.Supply
import Control.Monad.Trans.Control (MonadBaseControl(..))
import Control.Monad.Trans.Control (MonadBaseControl(..), control)
import Control.Monad.Trans.State (runStateT)
import Control.Monad.Writer.Class (MonadWriter(..), censor)
import Control.Monad.Writer.Strict (runWriterT)
Expand Down Expand Up @@ -146,6 +147,10 @@ make ma@MakeActions{..} ms = do
(fmap importPrim . snd $ CST.resFull m)
(deps `inOrderOf` map (getModuleName . CST.resPartial) sorted)

-- Prevent hanging on other modules when there is an internal error
-- (the exception is thrown, but other threads waiting on MVars are released)
`onExceptionLifted` BuildPlan.markComplete buildPlan moduleName (BuildJobFailed mempty)

-- Wait for all threads to complete, and collect results (and errors).
(failures, successes) <-
let
Expand Down Expand Up @@ -237,6 +242,9 @@ make ma@MakeActions{..} ms = do

BuildPlan.markComplete buildPlan moduleName result

onExceptionLifted :: m a -> m b -> m a
onExceptionLifted l r = control $ \runInIO -> runInIO l `onException` runInIO r

-- | Infer the module name for a module by looking for the same filename with
-- a .js extension.
inferForeignModules
Expand Down