chrome-pool
Advanced tools
Comparing version 1.1.1 to 1.1.3
@@ -161,9 +161,9 @@ 'use strict'; | ||
*/ | ||
release(tabId) { | ||
async release(tabId) { | ||
let tab = this.tabs[tabId]; | ||
tab.free = true; | ||
// navigate this tab to blank to release this tab's resource | ||
// https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-navigate | ||
tab.protocol.Page.navigate({ url: 'about:blank' }); | ||
await tab.protocol.Page.navigate({ url: 'about:blank' }); | ||
tab.free = true; | ||
@@ -176,3 +176,3 @@ // remove all listeners to fix MaxListenersExceededWarning: Possible EventEmitter memory leak detected | ||
}); | ||
}) | ||
}); | ||
@@ -179,0 +179,0 @@ if (this.requireResolveTasks.length > 0) { |
{ | ||
"name": "chrome-pool", | ||
"version": "1.1.1", | ||
"version": "1.1.3", | ||
"description": "headless chrome tabs manage pool", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -45,7 +45,5 @@ 'use strict'; | ||
console.log(`${maxTab} tabs has created, next require will return util a tab has be released after 2s`); | ||
setTimeout(() => { | ||
chromePoll.release(tabId1); | ||
chromePoll.release(tabId2); | ||
chromePoll.release(tabId3); | ||
chromePoll.release(tabId4); | ||
setTimeout(async () => { | ||
let task = [chromePoll.release(tabId1), chromePoll.release(tabId2), chromePoll.release(tabId3), chromePoll.release(tabId4)]; | ||
await Promise.all(task); | ||
Object.keys(chromePoll.tabs).forEach(tabId => { | ||
@@ -70,3 +68,3 @@ assert.equal(chromePoll.tabs[tabId].free, true, 'all tabs should be free now'); | ||
assert.equal(chromePoll.tabs[client.tabId].free, false, 'after require tab should be busy'); | ||
chromePoll.release(client.tabId); | ||
await chromePoll.release(client.tabId); | ||
assert.equal(chromePoll.tabs[client.tabId].free, true, 'after release tab should be free'); | ||
@@ -73,0 +71,0 @@ return await chromePoll.destroyPoll(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14131
278