mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
eaadc4bd30
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>
32 lines
709 B
JavaScript
32 lines
709 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const dgram = require('dgram');
|
|
|
|
{
|
|
// Test bad signal.
|
|
assert.throws(
|
|
() => dgram.createSocket({ type: 'udp4', signal: {} }),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError'
|
|
});
|
|
}
|
|
|
|
{
|
|
// Test close.
|
|
const controller = new AbortController();
|
|
const { signal } = controller;
|
|
const server = dgram.createSocket({ type: 'udp4', signal });
|
|
server.on('close', common.mustCall());
|
|
controller.abort();
|
|
}
|
|
|
|
{
|
|
// Test close with pre-aborted signal.
|
|
const signal = AbortSignal.abort();
|
|
const server = dgram.createSocket({ type: 'udp4', signal });
|
|
server.on('close', common.mustCall());
|
|
}
|