Repository: node
Issue: Socket.connect results in an abort
Labels: net

### Version

v22.11.0

### Platform

```text
Linux u24vm 6.8.0-50-generic #51-Ubuntu SMP PREEMPT_DYNAMIC Sat Nov  9 17:58:29 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
```

### Subsystem

net

### What steps will reproduce the bug?

Setup a node instance,
```
» node
```
and run the following javascript code.
```
net = require('net');
s = new net.Socket(()=>{});
s.connect({port:250,localAddress:'string'});
s.connect('string', ()=>{});
```
Then the node instance occurs an abort.

### How often does it reproduce? Is there a required condition?

This abort can always be triggered following the steps above.

### What is the expected behavior? Why is that the expected behavior?

If any error occurs, an exception or similar error-reporting stuff should be thrown, caught, and handled correctly. There is no reason to abort the whole node process.

### What do you see instead?

```
» node                                                                                               
Welcome to Node.js v22.11.0.
Type ".help" for more information.
> net = require('net');
{
  _createServerHandle: [Function: createServerHandle],
  _normalizeArgs: [Function: normalizeArgs],
  _setSimultaneousAccepts: [Function: _setSimultaneousAccepts],
  BlockList: [Getter],
  SocketAddress: [Getter],
  connect: [Function: connect],
  createConnection: [Function: connect],
  createServer: [Function: createServer],
  isIP: [Function: isIP],
  isIPv4: [Function: isIPv4],
  isIPv6: [Function: isIPv6],
  Server: [Function: Server],
  Socket: [Function: Socket],
  Stream: [Function: Socket],
  getDefaultAutoSelectFamily: [Function: getDefaultAutoSelectFamily],
  setDefaultAutoSelectFamily: [Function: setDefaultAutoSelectFamily],
  getDefaultAutoSelectFamilyAttemptTimeout: [Function: getDefaultAutoSelectFamilyAttemptTimeout],
  setDefaultAutoSelectFamilyAttemptTimeout: [Function: setDefaultAutoSelectFamilyAttemptTimeout]
}
> s = new net.Socket(()=>{});
Socket {
  connecting: false,
  _hadError: false,
  _parent: null,
  _host: null,
  _closeAfterHandlingError: false,
  _events: {
    close: undefined,
    error: undefined,
    prefinish: undefined,
    finish: undefined,
    drain: undefined,
    data: undefined,
    end: [Function: onReadableStreamEnd],
    readable: undefined
  },
  _readableState: ReadableState {
    highWaterMark: 65536,
    buffer: [],
    bufferIndex: 0,
    length: 0,
    pipes: [],
    awaitDrainWriters: null,
    [Symbol(kState)]: 1052932
  },
  _writableState: WritableState {
    highWaterMark: 65536,
    length: 0,
    corked: 0,
    onwrite: [Function: bound onwrite],
    writelen: 0,
    bufferedIndex: 0,
    pendingcb: 0,
    [Symbol(kState)]: 17564420,
    [Symbol(kBufferedValue)]: null
  },
  allowHalfOpen: false,
  _maxListeners: undefined,
  _eventsCount: 1,
  _sockname: null,
  _pendingData: null,
  _pendingEncoding: '',
  server: null,
  _server: null,
  [Symbol(async_id_symbol)]: -1,
  [Symbol(kHandle)]: null,
  [Symbol(lastWriteQueueSize)]: 0,
  [Symbol(timeout)]: null,
  [Symbol(kBuffer)]: null,
  [Symbol(kBufferCb)]: null,
  [Symbol(kBufferGen)]: null,
  [Symbol(shapeMode)]: true,
  [Symbol(kCapture)]: false,
  [Symbol(kSetNoDelay)]: false,
  [Symbol(kSetKeepAlive)]: false,
  [Symbol(kSetKeepAliveInitialDelay)]: 0,
  [Symbol(kBytesRead)]: 0,
  [Symbol(kBytesWritten)]: 0
}
> s.connect({port:250,localAddress:'string'});
Uncaught TypeError [ERR_INVALID_IP_ADDRESS]: Invalid IP address: string
    at lookupAndConnect (node:net:1289:11)
    at Socket.connect (node:net:1258:5) {
  code: 'ERR_INVALID_IP_ADDRESS'
}
> s.connect('string', ()=>{});

  #  node[2385420]: static void node::TCPWrap::Connect(const v8::FunctionCallbackInfo<v8::Value>&) at ../src/tcp_wrap.cc:290
  #  Assertion failed: args[2]->IsUint32()

----- Native stack trace -----

 1: 0xf76527 node::Assert(node::AssertionInfo const&) [node]
 2: 0x10d2fb3 node::TCPWrap::Connect(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 3: 0x7e29d7c0f5e2

----- JavaScript stack trace -----

1: internalConnect (node:net:1086:24)
2: defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
3: Socket.connect (node:net:1254:5)
4: REPL4:1:3
5: runInThisContext (node:vm:137:12)
6: defaultEval (node:repl:598:22)
7: bound (node:domain:433:15)
8: runBound (node:domain:444:12)
9: onLine (node:repl:927:10)
10: emit (node:events:530:35)


[1]    2385420 IOT instruction (core dumped)  node
```

### Additional information

_No response_