LRWebSocketConnection should listen for any socket errors#2
Open
compulim wants to merge 1 commit intolivereload:masterfrom
Open
LRWebSocketConnection should listen for any socket errors#2compulim wants to merge 1 commit intolivereload:masterfrom
compulim wants to merge 1 commit intolivereload:masterfrom
Conversation
Author
|
Ping. |
|
Override const LRWebSocketServer = require('livereload-server/lib/server');
/**
* prevent to crash socket with:
* -------------------------------------------------
* Error: read ECONNRESET
* at exports._errnoException (util.js:1022:11)
* at TCP.onread (net.js:569:26)
* -------------------------------------------------
*
* @see https://github.com/napcs/node-livereload/pull/15
*
*/
hackLRWebSocketServer() {
const orgCreateConnection = LRWebSocketServer.prototype._createConnection;
// replace https://github.com/livereload/livereload-server/blob/v0.2.3/lib/server.coffee#L74
LRWebSocketServer.prototype._createConnection = function(socket) {
// call original method with substituting 'this' obj
orgCreateConnection.call(this, socket);
socket.on('error', (err) => {
console.warn(`[WARN] Worthless error in client socket: '${err}'`);
});
}
} |
Driptap
pushed a commit
to Driptap/easy-livereload
that referenced
this pull request
Jul 23, 2018
- Listens for error events on the websocket instance to avoid uncaught ECONNRESET exceptions. When no listener is attached to error event from the websocket - the ECONNRESET expception is thrown: websockets/ws#1256 This is also somewhat relevant: livereload/livereload-server#2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
LRWebSocketConnectionshould listen for any socket errors, otherwise, when the underlying socket emiterrorevent due to TCP error, it will quit the host process.Sample scenario
The code below will crash
livereload-serverinstantlyIt will crash with the following error.