15407: Fixes app crash when webSocketUrl is not set on the API Server.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 20 Aug 2019 13:27:35 +0000 (10:27 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 20 Aug 2019 13:27:35 +0000 (10:27 -0300)
Instead, show a warning message on the JS console.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

src/websocket/websocket.ts

index e3f1e192023e8acda5aa84db991010b48a83d3e4..4fd7cc2c6c6d961d17bd5df4790af653fa02fca7 100644 (file)
@@ -15,9 +15,13 @@ import { addProcessLogsPanelItem } from '../store/process-logs-panel/process-log
 import { FilterBuilder } from "~/services/api/filter-builder";
 
 export const initWebSocket = (config: Config, authService: AuthService, store: RootStore) => {
-    const webSocketService = new WebSocketService(config.websocketUrl, authService);
-    webSocketService.setMessageListener(messageListener(store));
-    webSocketService.connect();
+    if (config.websocketUrl) {
+        const webSocketService = new WebSocketService(config.websocketUrl, authService);
+        webSocketService.setMessageListener(messageListener(store));
+        webSocketService.connect();
+    } else {
+        console.warn("WARNING: webSocketUrl is not configured on the API Server");
+    }
 };
 
 const messageListener = (store: RootStore) => (message: ResourceEventMessage) => {