-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Closed
Description
Looking at the code for Socket.connect
it seems that a socket that has been destroyed can be re-used.
However, the way the code is currently written (https://github.com/nodejs/node/blob/master/lib/net.js#L929) the socket can be undestroy
:ed while the socket hasn't finished destroying.
Consider the following:
const c = net.createConnection(common.PORT);
c.once('connect', () => {
c.destroy();
c.connect(common.PORT); // Uhoh?
});
const c = net.createConnection(common.PORT);
c.destroy();
c.connect(common.PORT); // Uhoh?
c.destroy();
c.connect(common.PORT); // Uhoh?
The socket is re-used directly after destroy
and _undestroy
is called, before the _destroy
callback has had a chance to run causing a potentially weird undefined state.
I believe we should wait for 'close'
in Socket.connect
before doing anything further to the instance.
Or am I missing something? @jasnell
Metadata
Metadata
Assignees
Labels
No labels