Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 846f304fa80c0bb6bc4585c6d0ddd23106153648 1 parent 20176a9
@trevnorris trevnorris authored tjfontaine committed
Showing with 7 additions and 4 deletions.
  1. +7 −4 test/simple/test-asynclistener-run-error-once.js
View
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();
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.