@@ -197,6 +197,7 @@ data Log
197
197
| LogShakeGarbageCollection ! T. Text ! Int ! Seconds
198
198
-- * OfInterest Log messages
199
199
| LogSetFilesOfInterest ! [(NormalizedFilePath , FileOfInterestStatus )]
200
+ | LogTimeOutShuttingDownWaitForSessionVar ! Seconds
200
201
deriving Show
201
202
202
203
instance Pretty Log where
@@ -240,6 +241,8 @@ instance Pretty Log where
240
241
LogSetFilesOfInterest ofInterest ->
241
242
" Set files of interst to" <> Pretty. line
242
243
<> indent 4 (pretty $ fmap (first fromNormalizedFilePath) ofInterest)
244
+ LogTimeOutShuttingDownWaitForSessionVar seconds ->
245
+ " Timed out waiting for session var after" <+> pretty seconds <+> " seconds"
243
246
244
247
-- | We need to serialize writes to the database, so we send any function that
245
248
-- needs to write to the database over the channel, where it will be picked up by
@@ -724,15 +727,18 @@ shakeSessionInit recorder ide@IdeState{..} = do
724
727
putMVar shakeSession initSession
725
728
logWith recorder Debug LogSessionInitialised
726
729
727
- shakeShut :: IdeState -> IO ()
728
- shakeShut IdeState {.. } = do
729
- runner <- tryTakeMVar shakeSession
730
- -- Shake gets unhappy if you try to close when there is a running
731
- -- request so we first abort that.
732
- for_ runner cancelShakeSession
733
- void $ shakeDatabaseProfile shakeDb
734
- progressStop $ progress shakeExtras
735
- stopMonitoring
730
+ shakeShut :: Recorder (WithPriority Log ) -> IdeState -> IO ()
731
+ shakeShut recorder IdeState {.. } = do
732
+ res <- timeout 1 $ withMVar shakeSession $ \ runner -> do
733
+ -- Shake gets unhappy if you try to close when there is a running
734
+ -- request so we first abort that.
735
+ cancelShakeSession runner
736
+ void $ shakeDatabaseProfile shakeDb
737
+ progressStop $ progress shakeExtras
738
+ stopMonitoring
739
+ case res of
740
+ Nothing -> logWith recorder Error $ LogTimeOutShuttingDownWaitForSessionVar 1
741
+ Just _ -> pure ()
736
742
737
743
738
744
-- | This is a variant of withMVar where the first argument is run unmasked and if it throws
0 commit comments