Skip to content

tls: handle ECONNRESET on the underlying socket #35829

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

Closed
wants to merge 1 commit into from

Conversation

mmomtchev
Copy link
Contributor

Add an error handler to the underlying TLSWrap socket
mostly for the occasional ECONNRESET that a Linux
kernel might throw under heavy load
Send a tlsClientError event in this case instead of an
uncatcheable socket error

Fixes: #35824

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Triggering this bug requires continuous heavy networking load, I am not sure if I should include a unit test

Add an error handler to the underlying TLSWrap socket
mostly for the occasional ECONNRESET that a Linux
kernel might throw under heavy load
Send a tlsClientError event in this case instead of an
uncatcheable socket error

Fixes: nodejs#35824
@nodejs-github-bot nodejs-github-bot added the tls Issues and PRs related to the tls subsystem. label Oct 27, 2020
@@ -1084,6 +1088,8 @@ function tlsConnectionListener(rawSocket) {

socket[kErrorEmitted] = false;
socket.on('close', onSocketClose);
// Handle ECONNRESET
socket.on('error', onSocketError);
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this 'error' event already handled by

this.on('error', this._tlsError);
?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right.
Yet, when the ECONNRESET error is triggered, there is no error handler.
I see there are a couple of cases where the handler is removed just before closing, so I guess it must have been one of those cases. I will dig further.

Copy link
Member

Choose a reason for hiding this comment

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

That listener is removed when the 'secureConnection' event is emitted but at that point it is user responsibility to handle the error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The user has no access to the underlying socket?

Copy link
Member

Choose a reason for hiding this comment

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

Yes they do, it's the "socket" that is passed to the handlers of the 'secureConnection' event.

@mmomtchev
Copy link
Contributor Author

I confirm, that error can be handled by the user

@mmomtchev mmomtchev closed this Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

read ECONNRESET at TLSWrap.onStreamRead
3 participants