diff --git a/keyserver/src/socket/socket.js b/keyserver/src/socket/socket.js --- a/keyserver/src/socket/socket.js +++ b/keyserver/src/socket/socket.js @@ -4,6 +4,7 @@ import invariant from 'invariant'; import _debounce from 'lodash/debounce.js'; import t from 'tcomb'; +import type { TUnion } from 'tcomb'; import WebSocket from 'ws'; import { baseLegalPolicies } from 'lib/facts/policies.js'; @@ -90,7 +91,7 @@ validateOutput, } from '../utils/validation-utils.js'; -const clientSocketMessageInputValidator = t.union([ +const clientSocketMessageInputValidator: TUnion = t.union([ tShape({ type: t.irreducible( 'clientSocketMessageTypes.INITIAL', @@ -190,10 +191,10 @@ let clientSocketMessage: ?ClientSocketMessage; try { this.resetTimeout(); - clientSocketMessage = JSON.parse(messageString); - checkInputValidator( + const messageObject = JSON.parse(messageString); + clientSocketMessage = checkInputValidator( clientSocketMessageInputValidator, - clientSocketMessage, + messageObject, ); if (clientSocketMessage.type === clientSocketMessageTypes.INITIAL) { if (this.viewer) {