summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Madsen <amwebdk@gmail.com>2012-06-08 20:24:52 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2012-06-09 18:15:38 +0200
commit60b45dcbb66ad754c70693adba80595ae67dc026 (patch)
tree3622fda0c3829d8ec1fd5bf9da9418433acdb25b
parent535e109a3ab8cc756504a9204fdcd428cbae7cba (diff)
downloadnode-60b45dcbb66ad754c70693adba80595ae67dc026.tar.gz
domain: document and test dispose event
-rw-r--r--doc/api/domain.markdown2
-rw-r--r--test/simple/test-domain-http-server.js8
2 files changed, 9 insertions, 1 deletions
diff --git a/doc/api/domain.markdown b/doc/api/domain.markdown
index f8df926ab..af868b650 100644
--- a/doc/api/domain.markdown
+++ b/doc/api/domain.markdown
@@ -258,6 +258,8 @@ The intention of calling `dispose` is generally to prevent cascading
errors when a critical part of the Domain context is found to be in an
error state.
+Once the domain is disposed the `dispose` event will emit.
+
Note that IO might still be performed. However, to the highest degree
possible, once a domain is disposed, further errors from the emitters in
that set will be ignored. So, even if some remaining actions are still
diff --git a/test/simple/test-domain-http-server.js b/test/simple/test-domain-http-server.js
index bd6336b57..f9962d3b8 100644
--- a/test/simple/test-domain-http-server.js
+++ b/test/simple/test-domain-http-server.js
@@ -28,7 +28,8 @@ var objects = { foo: 'bar', baz: {}, num: 42, arr: [1,2,3] };
objects.baz.asdf = objects;
var serverCaught = 0;
-var clientCaught = 0
+var clientCaught = 0;
+var disposeEmit = 0;
var server = http.createServer(function(req, res) {
var dom = domain.create();
@@ -84,6 +85,10 @@ function next() {
dom.dispose();
});
+ dom.on('dispose', function() {
+ disposeEmit += 1;
+ });
+
var req = http.get({ host: 'localhost', port: common.PORT, path: p });
dom.add(req);
req.on('response', function(res) {
@@ -111,5 +116,6 @@ function next() {
process.on('exit', function() {
assert.equal(serverCaught, 2);
assert.equal(clientCaught, 2);
+ assert.equal(disposeEmit, 2);
console.log('ok');
});