Skip to content

Commit a5ddf82

Browse files
committed
Prevent emitting socket event when socket is not ready yet.
1 parent 67ff2d5 commit a5ddf82

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/Server.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ function Server(compiler, options) {
2424
this.headers = options.headers;
2525

2626
this.sockWrite = function(type, data) {
27-
this.sock.write(JSON.stringify({type: type, data: data}));
27+
if (this.sock) {
28+
this.sock.write(JSON.stringify({type: type, data: data}));
29+
}
2830
}
2931

3032
// Listening for events
3133
var invalidPlugin = function() {
32-
if(this.sock) this.sockWrite("invalid");
34+
this.sockWrite("invalid");
3335
}.bind(this);
3436
compiler.plugin("compile", invalidPlugin);
3537
compiler.plugin("invalid", invalidPlugin);

0 commit comments

Comments
 (0)