Browse Source

test: fix async-listener-run-error-once

Rely on defined order of operations by closing the server and
destorying the client socket, instead of when setImmediate fires
v0.11.12-release
Trevor Norris 11 years ago
committed by Timothy J Fontaine
parent
commit
846f304fa8
  1. 11
      test/simple/test-asynclistener-run-error-once.js

11
test/simple/test-asynclistener-run-error-once.js

@ -24,11 +24,13 @@ var assert = require('assert');
var net = require('net');
var tracing = require('tracing');
var errMsg = 'net - error: server connection';
var cntr = 0;
var al = tracing.addAsyncListener({
error: function(stor, er) {
cntr++;
process._rawDebug('Handling error: ' + er.message);
assert.equal(errMsg, er.message);
return true;
}
});
@ -36,21 +38,22 @@ var al = tracing.addAsyncListener({
process.on('exit', function(status) {
tracing.removeAsyncListener(al);
console.log('exit status:', status);
assert.equal(status, 0);
console.log('cntr:', cntr);
assert.equal(cntr, 1);
console.log('ok');
});
var server = net.createServer(function(c) {
throw new Error('net - error: server connection');
this.close();
throw new Error(errMsg);
});
server.listen(common.PORT, function() {
net.connect(common.PORT, function() {
setImmediate(function() {
process.exit();
});
this.destroy();
});
});

Loading…
Cancel
Save