Skip to content

Agent: handle socket errors while connecting to the proxy#11

Open
someone--else wants to merge 1 commit intomscdex:masterfrom
someone--else:master
Open

Agent: handle socket errors while connecting to the proxy#11
someone--else wants to merge 1 commit intomscdex:masterfrom
someone--else:master

Conversation

@someone--else
Copy link
Copy Markdown

Passing client socket to the request on error allows it to be handled (vs aborting the process because of the unhandled exception)

…ed while connecting to the proxy are handled properly
@alchen
Copy link
Copy Markdown

alchen commented Feb 3, 2016

I was just checking out socksv5 and met with an uncaught exception, and this has helped. Thank you.

It'd be great If this can be merged, or someone can provide a pointer to another solution.

@wsz87
Copy link
Copy Markdown

wsz87 commented Mar 18, 2016

I agree It should be merged. It works for me too.

@mscdex
Copy link
Copy Markdown
Owner

mscdex commented Mar 20, 2016

I'm not sure this is the right approach. This PR seems to be passing a socket as "valid" whenever an error occurs. Is the point to allow the Agent implementation to be able to clean up the socket immediately after the error occurs? It seems like there may still be the possibility of the Agent to pass the socket out as valid for a short period of time?

Also while on the topic, I'm thinking of ditching the copy of node's internal http.Agent code for the async agent.createConnection() functionality which will arrive in node v6.0.0 and will simplify this code greatly.

@stroncium
Copy link
Copy Markdown

seems to be related #19

@Armalon
Copy link
Copy Markdown

Armalon commented Sep 28, 2016

Not sure if it's the right code to be merged with master, but it worked for me just fine. I was glad to be able to catch errors instead of application being dead.
Any ideas how to catch "Authentication failed" error using another method?

@GabrielLomba
Copy link
Copy Markdown

GabrielLomba commented Oct 9, 2019

I also encountered this error and made a change in the library that reemitted the error in the request object:

client.on('error', err=>req.emit('error', err));

This way, it allows Authentication Failed and other types of errors to be handled outside of the library.

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.

7 participants