src: don't error at startup when cwd doesn't exist
[platform/upstream/nodejs.git] / test / parallel / test-net-error-twice.js
1 var common = require('../common');
2 var assert = require('assert');
3 var net = require('net');
4
5 var buf = new Buffer(10 * 1024 * 1024);
6
7 buf.fill(0x62);
8
9 var errs = [];
10
11 var srv = net.createServer(function onConnection(conn) {
12   conn.write(buf);
13   conn.on('error', function (err) {
14     errs.push(err);
15     if (errs.length > 1 && errs[0] === errs[1])
16       assert(false, "We should not be emitting the same error twice");
17   });
18   conn.on('close', function() {
19     srv.unref();
20   });
21 }).listen(common.PORT, function () {
22   var client = net.connect({ port: common.PORT });
23
24   client.on('connect', function () {
25     client.destroy();
26   });
27 });
28
29 process.on('exit', function() {
30   console.log(errs);
31   assert.equal(errs.length, 1);
32 });