From 4a1827b5619da5f5e877263d06f108cae558f1cb Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Tue, 18 Jul 2017 19:01:06 +0200 Subject: Fix handler for empty websocket messages --- frontend/src/utils/websocket.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'frontend/src/utils/websocket.js') diff --git a/frontend/src/utils/websocket.js b/frontend/src/utils/websocket.js index b01531cf..6acd0806 100644 --- a/frontend/src/utils/websocket.js +++ b/frontend/src/utils/websocket.js @@ -41,7 +41,9 @@ export const createWsConnection = (headers: Object = {}): Promise { return eventChannel((emitter: (data: any) => void) => { const socketSubscription: SocketSubscriptionType = socket.subscribe(path, (event: SocketEventType) => { - emitter(JSON.parse(event.body)); + // not all events have a body + const value = event.body && JSON.parse(event.body); + emitter(value); }); return () => socketSubscription.unsubscribe(); }); -- cgit