puppeteer-extra: [Bug] My software stucks on browser.close with plugin-stealth 2.7.x version
My software stucks on browser.close with last version (puppeteer-extra-plugin-stealth)
Iโm using more than 1 browser open at the same time, and when Iโm trying to close 1 my software stucks. this has never happened with version 2.6.7 or before
my code:
var pages = await this.browser.pages()
for (let i = 0; i < pages.length; i++) {
await pages[i].close();
}
await this.browser.close();
Tested with 2.7.x version
if i downgrade to 2.6.7 everything works fine
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 56 (23 by maintainers)
Commits related to this issue
- Upgrade fs-extra, possible fix for #421 — committed to berstend/puppeteer-extra by Niek 3 years ago
- chore: Upgrade fs-extra, possible fix for #421 (#436) — committed to berstend/puppeteer-extra by Niek 3 years ago
- fix puppeteer-extra-plugin-stealth process hanging issue https://github.com/berstend/puppeteer-extra/issues/421#issuecomment-773656458 — committed to k-funk/us-embassy-passport-appointment-scraper by k-funk 3 years ago
- fix(plugin-user-data-dir): Use onDisconnect instead of onClose (#530) - Fixes #421 (freeze when using stealth on windows) — committed to DXCyber409/puppeteer-extra by dev-hyperweb 3 years ago
This should be fixed now through #530 (thanks @dev-hyperweb ๐ )
cc @LinkTree3 @Dam998
This happens for me as well with the default run settings listed in the documentation.
browser.close
locks up my terminal process. If I remove thepuppeteer-extra
requirement, and just go with the the vanillapuppeteer
, everything is fine. Thereโs definitely a core issue with this package.Literally just running the quickstart settings doesnโt work:
@LinkTree3 awesome, weโre gonna go with this fix then
I reproduced it with this simple script:
this script just open more browsers and then close them continusly with 2.6.7 version everything works good, with 2.7.x after the first browser close, the script freezes
and with 2.7.x if you try to do CTRL + C in terminal it not wll close, with 2.6.7 yes
Yes this one seems to work! I tested it a couple times to make sure ๐
I also added a console log right before and after the
fse.rmdirSync
call and they both fired after the puppeteer browser closed.@LinkTree3 no worries ๐ could you try if changing
onClose
toonDisconnected
(with the originalfse.rmdirSync
code) does make a difference in your case? https://github.com/berstend/puppeteer-extra/pull/530/filesThank you so much! looking forward to it ๐
Sweet! Thanks for testing ๐ So we know that (for whatever reason) removing the temporary profile folder synchronously can cause issues on windows, whereas doing it asynchronously works fine.
Iโm gonna prepare a fix + new version within the next days, as time permits.
YUP This did the trick! ๐Ok, one last test ๐
@LinkTree3 Cool, thanks for testing ๐
Would you be able to test if this change makes a difference (commenting the onClose handler back in)? https://github.com/berstend/puppeteer-extra/pull/502/files
(basically replacing
rmdirSync
withrmSync
)more specifically the onClose handler will result in this sync call: https://github.com/berstend/puppeteer-extra/blob/0049d6010311505f27e7f3be804bb198e2c09aa2/packages/puppeteer-extra-plugin-user-data-dir/index.js#L67-L76
Alright, to summarize what we know so far:
user-agent-override
evasion (unfortunately thatโs necessary to properly spoof locales)user-data-dir
plugin causes this behavior is not entirely clear yet, but my gut tells it must be this code: https://github.com/berstend/puppeteer-extra/blob/0049d6010311505f27e7f3be804bb198e2c09aa2/packages/puppeteer-extra-plugin-user-data-dir/index.js#L111-L116Can someone experiencing this issue monkey patch their
./node_modules/puppeteer-extra-plugin-user-data-dir/index.js
file and comment out thisonClose
handler to see if this fixes it?Hello, just wanted to report the same problem.
2.6.5
to2.7.6
.launch
and real Chrome 89.0.4389.90.2.6.5
fixes the problem.I tested again my script with 2.7.4 version and Iโm getting same error with 2.6.7 works fine
Gotcha. Thanks for the test case, weโll look into it. ๐