diff --git a/hls-graph.cabal b/hls-graph.cabal
--- a/hls-graph.cabal
+++ b/hls-graph.cabal
@@ -1,6 +1,6 @@
 cabal-version:      2.4
 name:               hls-graph
-version:            2.11.0.0
+version:            2.12.0.0
 synopsis:           Haskell Language Server internal graph API
 description:
   Please see the README on GitHub at <https://github.com/haskell/haskell-language-server/tree/master/hls-graph#readme>
diff --git a/src/Development/IDE/Graph/Internal/Key.hs b/src/Development/IDE/Graph/Internal/Key.hs
--- a/src/Development/IDE/Graph/Internal/Key.hs
+++ b/src/Development/IDE/Graph/Internal/Key.hs
@@ -34,6 +34,7 @@
     ) where
 
 --import Control.Monad.IO.Class ()
+import           Control.Exception             (evaluate)
 import           Data.Coerce
 import           Data.Dynamic
 import qualified Data.HashMap.Strict           as Map
@@ -85,8 +86,15 @@
 
 lookupKeyValue :: Key -> KeyValue
 lookupKeyValue (UnsafeMkKey x) = unsafePerformIO $ do
+  -- NOTE:
+  -- The reason for this evaluate is that the x, if not forced yet, is a thunk
+  -- that forces the atomicModifyIORef' in the creation of the new key. If it
+  -- isn't forced *before* reading the keyMap, the keyMap will only obtain the new
+  -- key (x) *after* the IntMap is already copied out of the keyMap reference,
+  -- i.e. when it is forced for the lookup in the IntMap.
+  k <- evaluate x
   GlobalKeyValueMap _ im _ <- readIORef keyMap
-  pure $! im IM.! x
+  pure $! im IM.! k
 
 {-# NOINLINE lookupKeyValue #-}
 
