Skip to content

Commit

Permalink
Merge pull request #10 from SkeLLLa/feature/add-clear-option-to-release
Browse files Browse the repository at this point in the history
Add clear option to release method
  • Loading branch information
gwuhaolin authored Aug 18, 2017
2 parents 99c90a8 + 01d2af7 commit 1db418f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,16 @@ class ChromePool {
/**
* call on a tab when your job on this tab is finished
* @param {string} tabId
* @param {boolean} clear - navigate to about:blank after release
*/
async release(tabId) {
async release(tabId, clear = true) {
let tab = this.tabs[tabId];

// navigate this tab to blank to release this tab's resource
// https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-navigate
await tab.protocol.Page.navigate({ url: 'about:blank' });
if (clear) {
await tab.protocol.Page.navigate({url: 'about:blank'});
}
tab.free = true;

// remove all listeners to fix MaxListenersExceededWarning: Possible EventEmitter memory leak detected
Expand Down

0 comments on commit 1db418f

Please sign in to comment.