-
Notifications
You must be signed in to change notification settings - Fork 357
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
Debugger connection retry logic #406
Conversation
throw new SocketException(); | ||
} | ||
} | ||
catch (Exception ex) |
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.
Do you expect any other exceptions than the SocketException you throw? If not, just filter this on that type and let the other exceptions naturally bubble up, this will preserve the stack better.
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.
Since you're not using the exception you catch, you should remove the 'ex' variable from the catch clause.
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.
I am using it in the WriteLine call immediately below.
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.
And yes, I do expect other exceptions. In fact, per the comment above the condition, I don't expect to have to throw the exception myself, that's just for safety. In general any exception trying to connect should cause either a retry or a rethrow after the max retries.
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.
In that case, I would add a message to the SocketException you throw to indicate that a networkclient was successfully created but not connected. That way we can investigate further if that happens.
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.
Yup, was going to do that, but there is no SocketException constructor that takes a string, and the Message property is read-only. ( https://msdn.microsoft.com/en-us/library/system.net.sockets.socketexception.socketexception(v=vs.110).aspx )
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.
I don't expect it to be an issue in ths case, but in general we don't want to swallow critical exceptions.
https://github.com/Microsoft/nodejstools/blob/35817ffdaa1797f95628a22f588fc3ed885f884b/Common/Product/SharedProject/ExceptionExtensions.cs#L23-L29
some minor comments and lgtm after that |
👍 |
This adds retry logic when attempting to connect to the debug port on Node, in an attempt to resolve #245 and #246.
In some scenarios, especially when using Debug builds of Node/io.js, the Node process doesn't open the debug port (5858 by default) in time. At the network level, this results in the connection being refused. This change adds retry logic if the connection fails (and additional logging).
On my machine, using the 'Debug' build of the latest io.js branch (as using 'Release' shows no issue at all), I can now see the connection retry and succeed, e.g.
Note that on a retry connect, sometime the debugger enters a state where it doesn't appear to be connected, but using "Debug / Break all" will then break on the first line and debugging can then continue. This needs to be looked at separately.