mirror of https://github.com/lukechilds/node.git
Browse Source
Emit errors using `.destroy(err)` instead of `.destroy()` and `.emit('error', err)`. Otherwise `close` event is emitted with the `error` argument set to `false`, even if the connection was torn down because of the error. See: https://github.com/nodejs/io.js/issues/1119 PR-URL: https://github.com/nodejs/io.js/pull/1711 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>v2.3.1-release
2 changed files with 64 additions and 14 deletions
@ -0,0 +1,42 @@ |
|||
'use strict'; |
|||
|
|||
var assert = require('assert'); |
|||
var common = require('../common'); |
|||
|
|||
if (!common.hasCrypto) { |
|||
console.log('1..0 # Skipped: missing crypto'); |
|||
process.exit(); |
|||
} |
|||
var tls = require('tls'); |
|||
|
|||
var fs = require('fs'); |
|||
var net = require('net'); |
|||
|
|||
var errorCount = 0; |
|||
var closeCount = 0; |
|||
|
|||
var server = tls.createServer({ |
|||
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), |
|||
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') |
|||
}, function(c) { |
|||
}).listen(common.PORT, function() { |
|||
var c = tls.connect(common.PORT, function() { |
|||
assert(false, 'should not be called'); |
|||
}); |
|||
|
|||
c.on('error', function(err) { |
|||
errorCount++; |
|||
}); |
|||
|
|||
c.on('close', function(err) { |
|||
if (err) |
|||
closeCount++; |
|||
|
|||
server.close(); |
|||
}); |
|||
}); |
|||
|
|||
process.on('exit', function() { |
|||
assert.equal(errorCount, 1); |
|||
assert.equal(closeCount, 1); |
|||
}); |
Loading…
Reference in new issue