Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions context.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function Namespace(name) {
this.id = null;
this._contexts = new Map();
this._indent = 0;
this._hook = null;
}

Namespace.prototype.set = function set(key, value) {
Expand Down Expand Up @@ -427,6 +428,8 @@ function createNamespace(name) {

hook.enable();

namespace._hook = hook;

process.namespaces[name] = namespace;
return namespace;
}
Expand All @@ -437,6 +440,15 @@ function destroyNamespace(name) {
assert.ok(namespace, 'can\'t delete nonexistent namespace! "' + name + '"');
assert.ok(namespace.id, 'don\'t assign to process.namespaces directly! ' + util.inspect(namespace));

namespace._hook.disable();

/*
* Zeroing _contexts as heaviest part of Namespace
* In case our namespace is retained mistakenly, so
* at least we are releasing heaviest part
*/
namespace._contexts = null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of typos, and this shouldn't be JSDoc block. Maybe:

/*
 * Zeroing _contexts as heaviest part of Namespace
 * In case our namespace is retained mistakenly, so
 * at least we are releasing heaviest part
 */

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree with these changes. Thanks for suggestions.


process.namespaces[name] = null;
}

Expand Down