File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -497,8 +497,15 @@ newSession IdeState{shakeExtras=ShakeExtras{..}, ..} systemActs userActs = do
497
497
let runInShakeSession :: forall a . Action a -> IO (IO a )
498
498
runInShakeSession act = do
499
499
res <- newBarrier
500
- let act' = actionCatch @ SomeException (Right <$> act) (pure . Left )
501
- atomically $ writeTQueue actionQueue (act' >>= liftIO . signalBarrier res)
500
+ let act' = do
501
+ -- work gets reenqueued when the Shake session is restarted
502
+ -- it can happen that a work item finished just as it was reenqueud
503
+ -- in that case, skipping the work is fine
504
+ alreadyDone <- liftIO $ isJust <$> waitBarrierMaybe res
505
+ unless alreadyDone $ do
506
+ x <- actionCatch @ SomeException (Right <$> act) (pure . Left )
507
+ liftIO $ signalBarrier res x
508
+ atomically $ writeTQueue actionQueue act'
502
509
return (waitBarrier res >>= either throwIO return )
503
510
504
511
-- Cancelling is required to flush the Shake database when either
You can’t perform that action at this time.
0 commit comments