Skip to content

Commit

Permalink
handle socket error, fix #104
Browse files Browse the repository at this point in the history
  • Loading branch information
creeperyang committed Aug 1, 2016
1 parent 749a6ea commit 303f95c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ Server.prototype.websocketify = function websocketify(req, socket, head) {
var client = new Client(req, socket, head, this.options);
this.clients[client.id] = client;

// handle socket error to prevent possible app crash, such as ECONNRESET
socket.on('error', function() {
self.error.apply(self, arguments);
});
debug('New LiveReload connection (id: %s)', client.id);
client.on('end', function() {
debug('Destroy client %s (url: %s)', client.id, client.url);
Expand All @@ -155,7 +159,7 @@ Server.prototype.websocketify = function websocketify(req, socket, head) {

Server.prototype.listen = function listen(port, host, fn) {
port = port || this.options.port;

//Last used port for error display
this.port = port;

Expand Down

2 comments on commit 303f95c

@matthewmueller
Copy link

@matthewmueller matthewmueller commented on 303f95c Oct 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change seems to be leading to tons of ... Uhoh. Got error undefined ... on 6.9.0 when you refresh the page.

@mklabs
Copy link
Owner

@mklabs mklabs commented on 303f95c Oct 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @matthewmueller I've opened a new issue to investigate this.

#113

Please sign in to comment.