diff --git a/lib/Server.js b/lib/Server.js index eaf879bee3..43e9896fa3 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -36,13 +36,13 @@ class Server { this.webSocketProxies = []; this.sockets = []; this.compiler = compiler; + this.currentHash = null; } static get DEFAULT_STATS() { return { all: false, hash: true, - assets: true, warnings: true, errors: true, errorDetails: false, @@ -1970,13 +1970,13 @@ class Server { // eslint-disable-next-line class-methods-use-this sendMessage(clients, type, data) { - clients.forEach((client) => { + for (const client of clients) { // `sockjs` uses `1` to indicate client is ready to accept data // `ws` uses `WebSocket.OPEN`, but it is mean `1` too if (client.readyState === 1) { client.send(JSON.stringify({ type, data })); } - }); + } } serveMagicHtml(req, res, next) { @@ -2011,8 +2011,7 @@ class Server { stats && (!stats.errors || stats.errors.length === 0) && (!stats.warnings || stats.warnings.length === 0) && - stats.assets && - stats.assets.every((asset) => !asset.emitted); + this.currentHash === stats.hash; if (shouldEmit) { this.sendMessage(clients, "still-ok"); @@ -2020,6 +2019,7 @@ class Server { return; } + this.currentHash = stats.hash; this.sendMessage(clients, "hash", stats.hash); if (stats.errors.length > 0 || stats.warnings.length > 0) {