@@ -197,6 +197,7 @@ data Log
197197 | LogShakeGarbageCollection ! T. Text ! Int ! Seconds
198198 -- * OfInterest Log messages
199199 | LogSetFilesOfInterest ! [(NormalizedFilePath , FileOfInterestStatus )]
200+ | LogTimeOutShuttingDownWaitForSessionVar ! Seconds
200201 deriving Show
201202
202203instance Pretty Log where
@@ -240,6 +241,8 @@ instance Pretty Log where
240241 LogSetFilesOfInterest ofInterest ->
241242 " Set files of interst to" <> Pretty. line
242243 <> indent 4 (pretty $ fmap (first fromNormalizedFilePath) ofInterest)
244+ LogTimeOutShuttingDownWaitForSessionVar seconds ->
245+ " Timed out waiting for session var after" <+> pretty seconds <+> " seconds"
243246
244247-- | We need to serialize writes to the database, so we send any function that
245248-- 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
724727 putMVar shakeSession initSession
725728 logWith recorder Debug LogSessionInitialised
726729
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 ()
736742
737743
738744-- | This is a variant of withMVar where the first argument is run unmasked and if it throws
0 commit comments