Commit 78ca61e
net: check args in net.connect() and socket.connect() calls
Previously Node.js would handle empty `net.connect()` and
`socket.connect()` call as if the user passed empty options object which
doesn't really make sense. This was due to the fact that it uses the
same `normalizeArgs` function as `.listen()` call where such call is
perfectly fine.
This will make it clear what is the problem with such call and how it
can be resolved. It now throws `ERR_MISSING_ARGS` if no arguments were
passed or neither `path` nor `port` is specified.
Fixes: #33930
PR-URL: #34022
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>1 parent b546a2b commit 78ca61eCopy full SHA for 78ca61e
File tree
Expand file treeCollapse file tree
7 files changed
+52
-15
lines changedOpen diff view settings
Filter options
- lib
- test/parallel
Expand file treeCollapse file tree
7 files changed
+52
-15
lines changedOpen diff view settings
Collapse file
+6-1Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | | - |
| 98 | + |
| 99 | + |
99 | 100 | |
100 | 101 | |
101 | 102 | |
| ||
921 | 922 | |
922 | 923 | |
923 | 924 | |
| 925 | + |
| 926 | + |
| 927 | + |
| 928 | + |
924 | 929 | |
925 | 930 | |
926 | 931 | |
|
Collapse file
test/parallel/test-net-connect-no-arg.js
Copy file name to clipboard+35Lines changed: 35 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 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
Collapse file
test/parallel/test-net-connect-options-port.js
Copy file name to clipboardExpand all lines: test/parallel/test-net-connect-options-port.js+1-2Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
60 | 60 | |
61 | 61 | |
62 | 62 | |
63 | | - |
| 63 | + |
64 | 64 | |
65 | 65 | |
66 | 66 | |
| ||
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | | - |
99 | 98 | |
100 | 99 | |
101 | 100 | |
|
Collapse file
test/parallel/test-net-normalize-args.js
Copy file name to clipboardExpand all lines: test/parallel/test-net-normalize-args.js+6-10Lines changed: 6 additions & 10 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
4 | 4 | |
5 | 5 | |
6 | 6 | |
7 | | - |
8 | 7 | |
9 | 8 | |
10 | 9 | |
| ||
27 | 26 | |
28 | 27 | |
29 | 28 | |
30 | | - |
31 | 29 | |
32 | 30 | |
33 | 31 | |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | | - |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
42 | 38 | |
43 | 39 | |
44 | 40 | |
|
Collapse file
test/parallel/test-tls-connect-allow-half-open-option.js
Copy file name to clipboardExpand all lines: test/parallel/test-tls-connect-allow-half-open-option.js+2-2Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
12 | 12 | |
13 | 13 | |
14 | 14 | |
15 | | - |
| 15 | + |
16 | 16 | |
17 | 17 | |
18 | 18 | |
19 | 19 | |
20 | | - |
| 20 | + |
21 | 21 | |
22 | 22 | |
23 | 23 | |
|
Collapse file
test/parallel/test-tls-connect-hints-option.js
Copy file name to clipboardExpand all lines: test/parallel/test-tls-connect-hints-option.js+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
22 | 22 | |
23 | 23 | |
24 | 24 | |
| 25 | + |
25 | 26 | |
26 | 27 | |
27 | 28 | |
|
Collapse file
test/parallel/test-tls-connect-timeout-option.js
Copy file name to clipboardExpand all lines: test/parallel/test-tls-connect-timeout-option.js+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
12 | 12 | |
13 | 13 | |
14 | 14 | |
| 15 | + |
15 | 16 | |
16 | 17 | |
17 | 18 | |
|
0 commit comments