Skip to content

Added error handling section to readme #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Juul
Copy link

@Juul Juul commented Feb 22, 2018

It isn't obvious that not having an error handler on the stream itself will cause problems down the line. Intuitively one might expect that handling errors on the underlying TCP socket would be enough but that's not the case. It took me a while to track down this problem in my own code so I thought I'd document and save others the trouble.

@mcollina
Copy link
Collaborator

Instead of fixing the documentation, can you provide a fix for the actual problem? I think we should not crash the application in that case.

@DmitryMyadzelets
Copy link

@mcollina is right. The example you'd like to add to the docs doesn't cover all cases, e.g. with no any http server. This module encapsulates the ws module, hence it should take care of it.

@Juul
Copy link
Author

Juul commented Mar 2, 2018

Alright if we don't want to crash because of an unhandled error, even when the user does not attach an error handler to the stream, then I don't see any way out of attaching a no-op error handler. Pull request #141 implements this.

I worry that my readme pull request caused some confusion: Attaching an error handler to the http server is not necessary. I wanted to show that even if attaching error handlers to the socket beneath the stream at all possible layers the error is not considered handled. Attaching a single error handler to the stream passed to the createServer callback is always enough in and of itself.

@mcollina
Copy link
Collaborator

mcollina commented Mar 2, 2018

I mean a completely different fix. Not just ignoring the error, but routing it to our websocket-stream, so only one error handler can be added.

socket.on('error', function(err) {
console.log("Client socket error:", err);
});
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the block that should not be needed, not the other one. Why is this needed?

@Juul
Copy link
Author

Juul commented Mar 3, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants