Skip to content

Commit f6e2a19

Browse files
fix: perf (#3906)
1 parent 625b9a8 commit f6e2a19

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/Server.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ class Server {
3636
this.webSocketProxies = [];
3737
this.sockets = [];
3838
this.compiler = compiler;
39+
this.currentHash = null;
3940
}
4041

4142
static get DEFAULT_STATS() {
4243
return {
4344
all: false,
4445
hash: true,
45-
assets: true,
4646
warnings: true,
4747
errors: true,
4848
errorDetails: false,
@@ -1970,13 +1970,13 @@ class Server {
19701970

19711971
// eslint-disable-next-line class-methods-use-this
19721972
sendMessage(clients, type, data) {
1973-
clients.forEach((client) => {
1973+
for (const client of clients) {
19741974
// `sockjs` uses `1` to indicate client is ready to accept data
19751975
// `ws` uses `WebSocket.OPEN`, but it is mean `1` too
19761976
if (client.readyState === 1) {
19771977
client.send(JSON.stringify({ type, data }));
19781978
}
1979-
});
1979+
}
19801980
}
19811981

19821982
serveMagicHtml(req, res, next) {
@@ -2011,15 +2011,15 @@ class Server {
20112011
stats &&
20122012
(!stats.errors || stats.errors.length === 0) &&
20132013
(!stats.warnings || stats.warnings.length === 0) &&
2014-
stats.assets &&
2015-
stats.assets.every((asset) => !asset.emitted);
2014+
this.currentHash === stats.hash;
20162015

20172016
if (shouldEmit) {
20182017
this.sendMessage(clients, "still-ok");
20192018

20202019
return;
20212020
}
20222021

2022+
this.currentHash = stats.hash;
20232023
this.sendMessage(clients, "hash", stats.hash);
20242024

20252025
if (stats.errors.length > 0 || stats.warnings.length > 0) {

0 commit comments

Comments
 (0)