Skip to content

Commit 4bc1ccc

Browse files
committed
dgram: pass null as error on successful send()
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>
1 parent 089c6a4 commit 4bc1ccc

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/dgram.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,10 @@ function doSend(ex, self, ip, buffer, address, port, callback) {
392392
function afterSend(err, sent) {
393393
if (err) {
394394
err = exceptionWithHostPort(err, 'send', this.address, this.port);
395+
} else {
396+
err = null;
395397
}
398+
396399
this.callback(err, sent);
397400
}
398401

test/parallel/test-dgram-send-callback-buffer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const client = dgram.createSocket('udp4');
99
const buf = Buffer.allocUnsafe(256);
1010

1111
const onMessage = common.mustCall(function(err, bytes) {
12+
assert.strictEqual(err, null);
1213
assert.equal(bytes, buf.length);
1314
clearTimeout(timer);
1415
client.close();

0 commit comments

Comments
 (0)