mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 12:45:25 +00:00

errorOrDestroy emits 'error' synchronously due to compat reasons. However, it should be possible to use correct async behaviour for new code. PR-URL: https://github.com/nodejs/node/pull/29744 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
23 lines
536 B
JavaScript
23 lines
536 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const net = require('net');
|
|
|
|
const server = net.createServer().listen(0, connectToServer);
|
|
|
|
function connectToServer() {
|
|
const client = net.createConnection(this.address().port, () => {
|
|
client.write(1337, common.expectsError({
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError'
|
|
}));
|
|
client.on('error', common.expectsError({
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError'
|
|
}));
|
|
|
|
client.destroy();
|
|
})
|
|
.on('close', () => server.close());
|
|
}
|