-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: support abortSignal in server.listen
PR-URL: #36623 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
4 changed files
with
70 additions
and
1 deletion.
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
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
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
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,33 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const net = require('net'); | ||
|
||
{ | ||
// Test bad signal. | ||
const server = net.createServer(); | ||
assert.throws( | ||
() => server.listen({ port: 0, signal: 'INVALID_SIGNAL' }), | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
name: 'TypeError' | ||
}); | ||
} | ||
|
||
{ | ||
// Test close. | ||
const server = net.createServer(); | ||
const controller = new AbortController(); | ||
server.on('close', common.mustCall()); | ||
server.listen({ port: 0, signal: controller.signal }); | ||
controller.abort(); | ||
} | ||
|
||
{ | ||
// Test close with pre-aborted signal. | ||
const server = net.createServer(); | ||
const controller = new AbortController(); | ||
controller.abort(); | ||
server.on('close', common.mustCall()); | ||
server.listen({ port: 0, signal: controller.signal }); | ||
} |