diff --git a/lib/dgram.js b/lib/dgram.js index 6b1772e6128dba..ac7a054a4c4681 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -358,6 +358,8 @@ Socket.prototype.close = function() { this._handle.close(); this._handle = null; this.emit('close'); + + return this; }; diff --git a/test/parallel/test-dgram-close.js b/test/parallel/test-dgram-close.js index 77af6f13b8011e..1eed54c91f4106 100644 --- a/test/parallel/test-dgram-close.js +++ b/test/parallel/test-dgram-close.js @@ -32,7 +32,7 @@ buf.fill(42); var socket = dgram.createSocket('udp4'); var handle = socket._handle; socket.send(buf, 0, buf.length, common.PORT, 'localhost'); -socket.close(); +assert.strictEqual(socket.close(), socket); socket = null; // Verify that accessing handle after closure doesn't throw