Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit e3413f0

Browse files
committed
net_uv: throw when people construct net.Socket(fd)
Easier to catch compatibility errors.
1 parent c4454d2 commit e3413f0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/net_uv.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ function Socket(options) {
8484

8585
stream.Stream.call(this);
8686

87+
if (typeof options == 'number') {
88+
// Legacy interface. Uncomment the following lines after
89+
// libuv backend is stable and API compatibile with legaacy.
90+
// console.error('Deprecated interface net.Socket(fd).');
91+
// console.trace();
92+
// Must support legacy interface. NPM depends on it.
93+
// https://github.com/isaacs/npm/blob/c7824f412f0cb59d6f55cf0bc220253c39e6029f/lib/utils/output.js#L110
94+
// TODO Before we can do this we need a way to open a uv_stream_t by fd.
95+
throw new Error("Not yet implemented")
96+
}
97+
8798
// private
8899
this._handle = options && options.handle;
89100
initSocketHandle(this);
@@ -245,7 +256,7 @@ Socket.prototype.destroy = function(exception) {
245256

246257
self._connectQueueCleanUp();
247258

248-
debug('destroy ' + this.fd);
259+
debug('destroy');
249260

250261
this.readable = this.writable = false;
251262

@@ -256,7 +267,7 @@ Socket.prototype.destroy = function(exception) {
256267
this.server._emitCloseIfDrained();
257268
}
258269

259-
debug('close ' + this.fd);
270+
debug('close');
260271
if (this._handle) {
261272
this._handle.close();
262273
this._handle = null;

0 commit comments

Comments
 (0)