Introduce post-connection timeout setting #531
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the timeout for the underlying socket is reset to
0
after a successful connection. This can lead to promises hanging indefinitely / callbacks not being invoked in case the server becomes unresponsive. On the other hand, just using the default socket timeout may be too short, and introduce runtime errors.As a solution, this change introduces a second socket option
postConnectTimeout
which is being applied to the socket after a successful connection, rather than resetting the timeout to0
. If the setting is not provided, a high default timeout of 300000 (5 minutes) is being set, which would still prevent indefinitely blocking clients.