-
-
Notifications
You must be signed in to change notification settings - Fork 744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] My software stucks on browser.close with plugin-stealth 2.7.x version #421
Comments
How are you opening the browsers, |
.launch |
Could you remove the const pluginStealth = require('puppeteer-extra-plugin-stealth')()
pluginStealth.enabledEvasions.delete('user-agent-override')
puppeteer.use(pluginStealth) |
The issue might be related to #413 - we save some state there and added functionality depending on how the browser is launched |
if I remove user-agent-override is working can I ask you why? if this is correct and nothing change at the end |
So it works without the The reason is to narrow down the problem, we made a larger update to the evasion so it makes sense the issue is somewhere there. If removing |
@Dam998 did you mean opening multiple browsers or multiple pages in a single browser? Your words indicate the former, your code the latter |
opening multiple browsers (more browsers, each browser with 2 pages) I created a class that on start() open a browser and then close it at the end, this is why |
@Dam998 do you also mind sharing a minimal reproducible code sample so we can check? |
Are you able to make a small self-contained test file? this helps us reproduce the issue quickly. Thanks! |
I'll try, give me some minutes |
I reproduced it with this simple script: const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
const locateChrome = require('locate-chrome');
const delay = require('delay');
(async () => {
console.log('start')
for (var i = 0; i < 20; i++) {
(async () => {
console.log('start')
try {
var chromeOptions = {
headless: false,
ignoreDefaultArgs: ['--disable-extensions'],
ignoreHTTPSErrors: true,
args: [
'--disable-web-security',
'--disable-dev-shm-usage',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-gpu',
'--ignore-certificate-errors',
'--enable-features=NetworkService'
],
};
let chromePath = await locateChrome()
chromeOptions.executablePath = chromePath;
puppeteer.use(StealthPlugin())
const browser = await puppeteer.launch(chromeOptions);
const page = await browser.newPage();
await page.goto('https://github.com/berstend/puppeteer-extra/issues/421', { 'waitUntil': 'domcontentloaded', timeout: 60000 });
await delay(13000);
var pages = await browser.pages()
for (let j = 0; j < pages.length; j++) {
await pages[j].close();
}
await browser.close();
}
catch (err) {
console.log(err)
}
})();
await delay(10000);
}
})(); this script just open more browsers and then close them continusly and with 2.7.x if you try to do CTRL + C in terminal it not wll close, with 2.6.7 yes |
Thanks! can't test right now but does it make a difference if you move |
nothing change this is only an example, I made this little mistake here but nothing change if I move it outside of the loop |
Gotcha. Thanks for the test case, we'll look into it. :-) |
I cannot reproduce this issue, your test script works fine for me @Dam998. I only got some memleak warnings but that's to be expected: $ node test.js
start
start
start
start
start
start
start
start
start
start
(node:70151) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:70151) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:70151) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:70151) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit
start
start
start
start
start
start
start
start
start
start
start @Dam998 can you run the following script and paste the output in a comment? npx envinfo@latest --system --binaries --npmPackages '*(puppeteer*|playwright*|automation-extra*|@extra*)' |
I tested again my script with 2.7.4 version and I'm getting same error |
@Dam998 pretty sure this is related to you using Windows in one way or another - our core team is all on POSIX. Are you using WSL to run this stuff? |
The issue is most likely somewhere in the user-data-dir plugin: Can you run your script with |
with version 2.7.4:
with version 2.7.4 everything stuck, the terminal too doesn't responde, I need always to force close it |
@berstend what do you think about bumping I think this might be the main cause: jprichardson/node-fs-extra#804 |
Yeah, bumping |
@Dam998 Please check with the latest master branch. |
I get this issue if I use |
@k-funk @KhalilMohammad this issue is Windows specific, please create a separate issue. Thanks! |
I am seeing the same issue right now. Is there any solution for this? I ended up reverting to 2.6.7 as well. It works for me for now. :) |
Alright, to summarize what we know so far:
Can someone experiencing this issue monkey patch their |
more specifically the onClose handler will result in this sync call:
|
Hey thank you so much for looking into this! Yes I'll gladly check this and report. :) |
Yes your suggestion worked! :) Now how do we fix it permanently without needing to resort to monkey patching? |
@LinkTree3 Cool, thanks for testing :) Would you be able to test if this change makes a difference (commenting the onClose handler back in)? (basically replacing |
it clearly. this issued stuck in onClose event so if im not wrong, even empty event still stuck |
This did not work. |
Ok, one last test :) fs.rm(this._userDataDir, { recursive: true, force: true }, console.log) |
|
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. |
Thank you so much! looking forward to it :) |
berstend I am so sorry, but it seems that I might have had a mistake while testing it with Now when I try it again it seems to not work :( I am getting an EBUSY error and a bunch of "null" when I try to exit [Error: EBUSY: resource busy or locked, unlink 'C:\Users[username]\AppData\Local\Temp\puppeteer_dev_profile-1BHM2o\lockfile'] { |
@LinkTree3 no worries :) could you try if changing |
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 |
@LinkTree3 awesome, we're gonna go with this fix then |
This should be fixed now through #530 (thanks @dev-hyperweb 👍 )
|
More properly fixed in #656 |
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:
Tested with 2.7.x version
if i downgrade to 2.6.7 everything works fine
The text was updated successfully, but these errors were encountered: