Fix erroneous error logging in WebSocket.onStop

This commit is contained in:
Brandon Simmons 2020-04-08 11:59:46 -04:00 committed by Vamshi Surabhi
parent 1fbf647c0d
commit 8b85c86ebe
2 changed files with 11 additions and 3 deletions

View File

@ -64,6 +64,7 @@ Read more about check constraints on [Postgres Docs](https://www.postgresql.org/
- server: preserve cookie headers from sync action webhook (close #4021)
- server: validate action webhook response to conform to action output type (fix #3977)
- server: add 'ID' to default scalars in custom types (fix #4061)
- server: fix erroneous error log "Received STOP for an operation ..."
- console: enum field values can be selected through a dropdown in insert/edit rows page (close #3748) (#3810)
- console: exported metadata filenames are now unique(`hasura_metadata_<timestamp>.json`) (close #1772) (#4106)
- console: allow bulk deleting rows in 'Browse Rows' section (close #1739) (#3735)

View File

@ -487,15 +487,22 @@ onMessage authMode serverEnv wsConn msgRaw =
onStop :: WSServerEnv -> WSConn -> StopMsg -> IO ()
onStop serverEnv wsConn (StopMsg opId) = do
-- When a stop message is received for an operation, it may not be present in OpMap
-- in these cases:
-- 1. If the operation is a query/mutation - as we remove the operation from the
-- OpMap as soon as it is executed
-- 2. A misbehaving client
-- 3. A bug on our end
opM <- liftIO $ STM.atomically $ STMMap.lookup opId opMap
case opM of
Just (lqId, opNameM) -> do
logWSEvent logger wsConn $ EOperation $ opDet opNameM
LQ.removeLiveQuery logger lqMap lqId
Nothing ->
L.unLogger logger $ L.UnstructuredLog L.LevelError $ fromString $
"Received STOP for an operation "<>(show opId)<>" we have no record for. "<>
"this could be a misbehaving client or a bug"
L.unLogger logger $ L.UnstructuredLog L.LevelDebug $ fromString $
"Received STOP for an operation that we have no record for: "
<> show (unOperationId opId)
<> " (could be a query/mutation operation or a misbehaving client or a bug)"
STM.atomically $ STMMap.delete opId opMap
where
logger = _wseLogger serverEnv