| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5c9576b commit 788976c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -295,7 +295,7 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { | |||
| 295 | 295 | const cb = arguments.length && arguments[arguments.length - 1]; | |
| 296 | 296 | if (typeof cb === 'function') { | |
| 297 | 297 | function removeListeners() { | |
| 298 | - this.removeListener('error', removeListeners); | ||
| 298 | + this.removeListener(EventEmitter.errorMonitor, removeListeners); | ||
| 299 | 299 | this.removeListener('listening', onListening); | |
| 300 | 300 | } | |
| 301 | 301 | ||
@@ -304,7 +304,7 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { | |||
| 304 | 304 | FunctionPrototypeCall(cb, this); | |
| 305 | 305 | } | |
| 306 | 306 | ||
| 307 | - this.on('error', removeListeners); | ||
| 307 | + this.on(EventEmitter.errorMonitor, removeListeners); | ||
| 308 | 308 | this.on('listening', onListening); | |
| 309 | 309 | } | |
| 310 | 310 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,23 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('node:assert'); | ||
| 4 | + const dgram = require('node:dgram'); | ||
| 5 | + | ||
| 6 | + // Ensure that bind errors (e.g. EADDRINUSE) are not silently swallowed | ||
| 7 | + // when socket.bind() is called with a callback but without a user | ||
| 8 | + // 'error' handler. | ||
| 9 | + | ||
| 10 | + const socket1 = dgram.createSocket('udp4'); | ||
| 11 | + | ||
| 12 | + socket1.bind(0, common.mustCall(() => { | ||
| 13 | + const { port } = socket1.address(); | ||
| 14 | + const socket2 = dgram.createSocket('udp4'); | ||
| 15 | + | ||
| 16 | + process.on('uncaughtException', common.mustCall((err) => { | ||
| 17 | + assert.strictEqual(err.code, 'EADDRINUSE'); | ||
| 18 | + socket1.close(); | ||
| 19 | + socket2.close(); | ||
| 20 | + })); | ||
| 21 | + | ||
| 22 | + socket2.bind({ port }, common.mustNotCall()); | ||
| 23 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments