Skip to content

Commit aa30eb5

Browse files
addaleaxtargos
authored andcommitted
dgram: reset bind state before emitting error
This was previously done inconsistently, sometimes before, sometimes after emitting the event. PR-URL: #30210 Fixes: #30209 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f97f1ca commit aa30eb5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/dgram.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) {
240240
}, (err) => {
241241
// Callback to handle error.
242242
const ex = errnoException(err, 'open');
243-
this.emit('error', ex);
244243
state.bindState = BIND_STATE_UNBOUND;
244+
this.emit('error', ex);
245245
});
246246
return this;
247247
}
@@ -309,8 +309,8 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) {
309309
}, (err) => {
310310
// Callback to handle error.
311311
const ex = exceptionWithHostPort(err, 'bind', ip, port);
312-
this.emit('error', ex);
313312
state.bindState = BIND_STATE_UNBOUND;
313+
this.emit('error', ex);
314314
});
315315
} else {
316316
if (!state.handle)
@@ -319,8 +319,8 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) {
319319
const err = state.handle.bind(ip, port || 0, flags);
320320
if (err) {
321321
const ex = exceptionWithHostPort(err, 'bind', ip, port);
322-
this.emit('error', ex);
323322
state.bindState = BIND_STATE_UNBOUND;
323+
this.emit('error', ex);
324324
// Todo: close?
325325
return;
326326
}

0 commit comments

Comments
 (0)