Logo
Explore Help
Sign In
1berry/nodejs
1
0
Fork 0
You've already forked nodejs
Code Issues Packages Projects Releases Wiki Activity
nodejs/test/parallel/test-net-socket-destroy-twice.js

24 lines
396 B
JavaScript
Raw Normal View History

test: enable linting for tests Enable linting for the test directory. A number of changes was made so all tests conform the current rules used by lib and src directories. The only exception for tests is that unreachable (dead) code is allowed. test-fs-non-number-arguments-throw had to be excluded from the changes because of a weird issue on Windows CI. PR-URL: https://github.com/nodejs/io.js/pull/1721 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-05-19 13:00:06 +02:00
'use strict';
net: don't emit 'close' event twice Don't allow `socket.destroy()` to run twice. The self-destruct sequence itself is idempotent but it makes the 'close' and 'error' events fire more than once, which may confuse listeners. Fixes #2223.
2011-12-01 14:51:53 +01:00
var common = require('../common');
var assert = require('assert');
var net = require('net');
var nerrors = 0;
var ncloses = 0;
process.on('exit', function() {
assert.equal(nerrors, 1);
assert.equal(ncloses, 1);
});
var conn = net.createConnection(common.PORT);
conn.on('error', function() {
nerrors++;
conn.destroy();
});
conn.on('close', function() {
ncloses++;
});
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 711ms Template: 4ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API