Commit 18c057a
net: emit 'close' when socket ends before connect
Don't set `writable` to true when a socket connects if the socket is
already in an ending state.
In the existing code, afterConnect always set `writable` to true. This
has been the case for a long time, but previous to commit
9b7a691, the socket would still be
destroyed by `destroySoon` and emit a `'close'` event. Since that
commit removed this masking behavior, we have relied on maybeDestroy to
destroy the socket when the readble state is ended, and that won't
happen if `writable` is set to true.
If the socket has `allowHalfOpen` set to true, then `destroy` will still
not be called and `'close'` will not be emitted.
PR-URL: #21290
Fixes: #21268
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>1 parent 6285fe9 commit 18c057aCopy full SHA for 18c057a
File tree
Expand file treeCollapse file tree
2 files changed
+15
-1
lines changedOpen diff view settings
Filter options
- lib
- test/parallel
Expand file treeCollapse file tree
2 files changed
+15
-1
lines changedOpen diff view settings
Collapse file
+2-1Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1138 | 1138 | |
1139 | 1139 | |
1140 | 1140 | |
1141 | | - |
| 1141 | + |
| 1142 | + |
1142 | 1143 | |
1143 | 1144 | |
1144 | 1145 | |
|
Collapse file
test/parallel/test-net-socket-end-before-connect.js
Copy file name to clipboard+13Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
0 commit comments