mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 15:41:06 +00:00

PR-URL: https://github.com/nodejs/node/pull/37798 Refs: https://github.com/whatwg/dom/pull/960 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com>
33 lines
755 B
JavaScript
33 lines
755 B
JavaScript
'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 signal = AbortSignal.abort();
|
|
server.on('close', common.mustCall());
|
|
server.listen({ port: 0, signal });
|
|
}
|