-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Close outgoing socket (fixes #559) #561
Conversation
head and error handling was broken before this commit.
Fixes http-party#559, which contains a full reproduction recipe.
// if it errors (eg, vanishes from the net and starts returning | ||
// EHOSTUNREACH). We need to do that explicitly. | ||
socket.on('error', function () { | ||
proxySocket.end(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also call onOutgoingError
here since ending the proxySocket
won't trigger its error event in anyway.
@glasser besides my comment, LGTM. Good find! |
Ok, in that case it probably shouldn't be called onOutgoingError. What should the event's args be? Right now the error event always gets the incoming socket as an arg even though the error is on the outgoing one. Should there be some way for the event to indicate which socket had the error? |
@glasser Well lets think of what we can do in these failure cases. Correct me if I'm wrong here, but in the case where the thoughts @yawnt? |
I don't think it is necessary to As to how to differentiate, seems like a design choice for the module maintainers... should there be lots of different error events with different names (which is what caronte seemed to originally have when it was using EventEmitter2) or a single error event with different parameters? |
@glasser I'm going to cherry pick part of this since the other PR was merged. And until I have a better idea of how the errors should be handled from messing around with the fail cases, I think we'll just emit the |
Hmm actually I recant this, I don't believe we can really do anything if the client's socket errors so we just have to wait for them to reconnect. Emitting an error is actually not useful so your solution seems like the best course. The only reason I see for emitting some kind of event is for logging purposes. It should not be under |
Note that this includes #560.