From 34cafc77e847498bde1c019c8b9a06252b4bae4a Mon Sep 17 00:00:00 2001 From: Cryptomental Date: Mon, 1 Oct 2018 22:58:42 +0200 Subject: [PATCH] webserver: Emit websocket outputError and show error on the landing page. Whenever outputError is emitted by Ember, display error message on the landing page and stop the page from refreshing every four seconds. Refs: https://github.com/embark-framework/embark/issues/946 --- lib/modules/webserver/server.js | 5 +++++ .../webserver/templates/embark-building-placeholder.html.ejs | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/modules/webserver/server.js b/lib/modules/webserver/server.js index bea969cb7..2a921e295 100644 --- a/lib/modules/webserver/server.js +++ b/lib/modules/webserver/server.js @@ -44,6 +44,11 @@ class Server { wss.clients.forEach(function (client) { client.send('outputDone'); }); + self.events.on('outputError', () => { + if (ws.readyState === WEB_SOCKET_STATE_OPEN) { + return ws.send('outputError'); + } + }); }); async.waterfall([ diff --git a/lib/modules/webserver/templates/embark-building-placeholder.html.ejs b/lib/modules/webserver/templates/embark-building-placeholder.html.ejs index 4785d8e43..4e77c6917 100644 --- a/lib/modules/webserver/templates/embark-building-placeholder.html.ejs +++ b/lib/modules/webserver/templates/embark-building-placeholder.html.ejs @@ -30,7 +30,10 @@ ws.addEventListener('message', (evt) => { if(evt.data === 'outputDone') { location.reload(true); + } else if(evt.data === 'outputError') { + document.getElementsByClassName("loading-msg")[0].innerHTML = "Error building dapp, please check console"; + window.stop() } }); - \ No newline at end of file +