mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Signed-off-by: armanmikoyan <arman.mikoyan1@gmail.com> PR-URL: https://github.com/nodejs/node/pull/62602 Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
24 lines
670 B
JavaScript
24 lines
670 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('node:assert');
|
|
const dgram = require('node:dgram');
|
|
|
|
// Ensure that bind errors (e.g. EADDRINUSE) are not silently swallowed
|
|
// when socket.bind() is called with a callback but without a user
|
|
// 'error' handler.
|
|
|
|
const socket1 = dgram.createSocket('udp4');
|
|
|
|
socket1.bind(0, common.mustCall(() => {
|
|
const { port } = socket1.address();
|
|
const socket2 = dgram.createSocket('udp4');
|
|
|
|
process.on('uncaughtException', common.mustCall((err) => {
|
|
assert.strictEqual(err.code, 'EADDRINUSE');
|
|
socket1.close();
|
|
socket2.close();
|
|
}));
|
|
|
|
socket2.bind({ port }, common.mustNotCall());
|
|
}));
|