mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
d405a606ab
PR-URL: https://github.com/nodejs/node/pull/51914 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
20 lines
519 B
JavaScript
20 lines
519 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const dgram = require('dgram');
|
|
|
|
// Do not emit error event in callback which is called by lookup when socket is closed
|
|
const socket = dgram.createSocket({
|
|
type: 'udp4',
|
|
lookup: (...args) => {
|
|
// Call lookup callback after 1s
|
|
setTimeout(() => {
|
|
args.at(-1)(new Error('an error'));
|
|
}, 1000);
|
|
}
|
|
});
|
|
|
|
socket.on('error', common.mustNotCall());
|
|
socket.bind(12345, 'localhost');
|
|
// Close the socket before calling DNS lookup callback
|
|
socket.close();
|