Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion client-src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const onSocketMessage = {

self.location.reload();
},
warnings(warnings) {
warnings(warnings, params) {
log.warn("Warnings while compiling.");

const printableWarnings = warnings.map((error) => {
Expand All @@ -183,6 +183,12 @@ const onSocketMessage = {
if (needShowOverlayForWarnings) {
show("warning", warnings);
}

if (params && params.preventReloading) {
return;
}

reloadApp(options, status);
},
errors(errors) {
log.error("Errors while compiling. Reload prevented.");
Expand Down
2 changes: 1 addition & 1 deletion client-src/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const socket = function initSocket(url, handlers, reconnect) {
const message = JSON.parse(data);

if (handlers[message.type]) {
handlers[message.type](message.data);
handlers[message.type](message.data, message.params);
}
});
};
Expand Down
14 changes: 11 additions & 3 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2148,12 +2148,12 @@ class Server {
}

// eslint-disable-next-line class-methods-use-this
sendMessage(clients, type, data) {
sendMessage(clients, type, data, params) {
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 }));
client.send(JSON.stringify({ type, data, params }));
}
}
}
Expand Down Expand Up @@ -2202,8 +2202,16 @@ class Server {
this.sendMessage(clients, "hash", stats.hash);

if (stats.errors.length > 0 || stats.warnings.length > 0) {
const hasErrors = stats.errors.length > 0;

if (stats.warnings.length > 0) {
this.sendMessage(clients, "warnings", stats.warnings);
let params;

if (hasErrors) {
params = { preventReloading: true };
}

this.sendMessage(clients, "warnings", stats.warnings, params);
}

if (stats.errors.length > 0) {
Expand Down
Loading