Skip to content

Network socket not correctly cleaned up when connection timeout fires during TDS8.0 TLS negotiation #1558

Description

@arthurschreiber

The recently added Connection#wrapWithTls method does not behave correctly if the connection timeout fires during the TLS negotiation.

When the connect timeout fires, we dispatch a ConnectionError to the connect event and move the internal state over to the FINAL state. Because we haven't fully connected yet, the network socket does not get cleaned up when moving to the FINAL state.

When the connection timeout fires between the call to connect and before wrapWithTls returns, we never clean up the socket correctly, because wrapWithTls doesn't return an error if the connection timeout fires.

I think this can be fixed by making wrapWithTls take the signal passed to connectOnPort, and handle it correctly (i.e. call signal.throwIfError at the beginning of the function, and set the correct event handlers to reject the promise if the signal is aborted).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions