Skip to content

Commit

Permalink
dgram: pass null as error on successful send()
Browse files Browse the repository at this point in the history
Prior to c9fd9e2, UDP sockets
would callback with a null error on successful send() calls. The
current behavior is to pass 0 as the error. This commit restores
the previous, more expected behavior.

PR-URL: #5929
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
  • Loading branch information
cjihrig committed Mar 28, 2016
1 parent 089c6a4 commit 4bc1ccc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,10 @@ function doSend(ex, self, ip, buffer, address, port, callback) {
function afterSend(err, sent) {
if (err) {
err = exceptionWithHostPort(err, 'send', this.address, this.port);
} else {
err = null;
}

this.callback(err, sent);
}

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-dgram-send-callback-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const client = dgram.createSocket('udp4');
const buf = Buffer.allocUnsafe(256);

const onMessage = common.mustCall(function(err, bytes) {
assert.strictEqual(err, null);
assert.equal(bytes, buf.length);
clearTimeout(timer);
client.close();
Expand Down

0 comments on commit 4bc1ccc

Please sign in to comment.