Skip to content

Commit

Permalink
Fixed a memory leak when adding too many event listeners to uncoughte…
Browse files Browse the repository at this point in the history
…xeption in the callbacks for QueuedItem
  • Loading branch information
camme committed May 13, 2013
1 parent 21a4f14 commit 9185809
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions lib/utils/QueueItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ var QueueItem = module.exports = function(commandName, method, scope, args) {
nextCallback = function(method, methodName) {
return function(err,result) {

process.on('uncaughtException', function (exception) {
function errorCB() {
self.next();
});
}

process.on('uncaughtexception', errorCB);

// call the callback
method.call(scope, err, result);

// call the next item
self.next();

// remove the listener to avoid memoryleakes. but do it after self.next so we know everything went well
process.removeListener('uncaughtexception', errorCB);

};
};

Expand Down Expand Up @@ -153,4 +160,4 @@ var QueueItem = module.exports = function(commandName, method, scope, args) {

return child;
};
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "webdriverjs",
"description": "A nodejs bindings implementation for selenium 2.0/webdriver",
"version": "0.7.2",
"version": "0.7.3",
"homepage": "https://github.com/Camme/webdriverjs",
"author": "camilo tapia <[email protected]>",
"contributors": [
Expand Down

0 comments on commit 9185809

Please sign in to comment.