From aa30eb518289028b57126e878379a5685ef0007c Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 1 Nov 2019 19:50:16 +0100 Subject: [PATCH] dgram: reset bind state before emitting error This was previously done inconsistently, sometimes before, sometimes after emitting the event. PR-URL: https://github.com/nodejs/node/pull/30210 Fixes: https://github.com/nodejs/node/issues/30209 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- lib/dgram.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/dgram.js b/lib/dgram.js index cc61d4d274eea1..c365df2414f99d 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -240,8 +240,8 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { }, (err) => { // Callback to handle error. const ex = errnoException(err, 'open'); - this.emit('error', ex); state.bindState = BIND_STATE_UNBOUND; + this.emit('error', ex); }); return this; } @@ -309,8 +309,8 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { }, (err) => { // Callback to handle error. const ex = exceptionWithHostPort(err, 'bind', ip, port); - this.emit('error', ex); state.bindState = BIND_STATE_UNBOUND; + this.emit('error', ex); }); } else { if (!state.handle) @@ -319,8 +319,8 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { const err = state.handle.bind(ip, port || 0, flags); if (err) { const ex = exceptionWithHostPort(err, 'bind', ip, port); - this.emit('error', ex); state.bindState = BIND_STATE_UNBOUND; + this.emit('error', ex); // Todo: close? return; }