This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: destroy sockets on close (#204)
* fix: destroy sockets on close We call `.end` on a socket and wait for the `close` event, but calling `.end` only closes the writable end of the socket. To close both ends we either need to wait for the remote to close their writable end or we need to `.destroy` our socket. If we call `.destroy` all data is lost and no more I/O occurs. The change here is to call `.end` then check to see if we have any outgoing writes, if we do, wait for the `drain` event which means the outgoing data has been sent, then call `.destroy`, otherwise call `.destroy` immediately. At the same time use a timer to call `.destroy` if the `drain` event never arrives. It also set up the `timeout` event for the socket to allow closing the socket after a period of inactivity. Three new constructor options are added to control the behvaiour: - `inboundSocketInactivityTimeout` the socket will be closed after this many ms of not sending/recieving data (default 30s) - `outboundSocketInactivityTimeout` the socket will be closed after this many ms of not sending/recieving data (default 30s) - `socketCloseTimeout` how long to wait for the `drain` event (default 2s) Fixes #201 * chore: account for networking differences * chore: ignore client errors
- Loading branch information
1 parent
3ac4be4
commit e8b8f2e
Showing
7 changed files
with
570 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.