-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: return directly if udp socket close before lookup
PR-URL: #51914 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
- Loading branch information
Showing
2 changed files
with
22 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
test/parallel/test-dgram-bind-socket-close-before-lookup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'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(); |