-
-
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] puppeteer-extra-plugin:user-data-dir.onClose called twice and causes Error. Also possible memory leak with Plugins #559
Comments
Also considering running in a row launch/close all the errors are reported at the end of whole script. It looks like something (Plugin instances at least) are not released until the end of script and probably can be a reason of memory issues. UPDATE and as you can find all the latest calls are for the same latest folder! It is overall correct that "puppeteer-extra-plugin:user-data-dir" contains properties like "_userDataDir", "_isTemporary"? UPDATE see next comment with updated code snippet import {addExtra} from "puppeteer-extra";
let puppeteer = require('puppeteer');
puppeteer = addExtra(puppeteer);
const UserAgentOverride = require("puppeteer-extra-plugin-stealth/evasions/user-agent-override");
puppeteer.use(UserAgentOverride());
async function runOne() {
const browser = await puppeteer.launch({headless: true});
console.log('Start');
await browser.close();
console.log('Done');
}
(async function main() {
await runOne();
await runOne();
await runOne();
await new Promise(resolve => setTimeout(resolve, 5000));
console.log('DONE WAIT');
})();
|
Probably properProbably proper test case tht solves issue with same folder name. Main issue is still here import {addExtra} from "puppeteer-extra";
const puppeteerCore = require('puppeteer');
async function runOne() {
let puppeteer = addExtra(puppeteerCore);
const UserAgentOverride = require("puppeteer-extra-plugin-stealth/evasions/user-agent-override");
puppeteer.use(UserAgentOverride());
const browser = await puppeteer.launch({headless: true} as any);
console.log('Start');
await browser.close();
console.log('Done');
}
(async function main() {
await runOne();
await runOne();
await runOne();
await new Promise(resolve => setTimeout(resolve, 5000));
console.log('DONE WAIT');
})(); |
Looks like because of PuppeteerExtraPlugin._bindBrowserEvents : [skipped]
if (this.onClose) {
process.on('exit', this.onClose.bind(this));
browser.on('disconnected', this.onClose.bind(this));
if (opts.options.handleSIGINT !== false) {
process.on('SIGINT', this.onClose.bind(this));
}
if (opts.options.handleSIGTERM !== false) {
process.on('SIGTERM', this.onClose.bind(this));
}
if (opts.options.handleSIGHUP !== false) {
process.on('SIGHUP', this.onClose.bind(this));
}
}
[skipped] All the plugin instances with "onClose" are not released on browser close, stays in memory until end of the script and cause memory leak in case of long run. Do I miss something? |
I use 3.1.18. But in master I still see
That prevents proper release Plugin instances on browser close and keep them in memory until process end. |
I meant the plugins:
In addition we could "debounce" the |
But yeah, it seems like you're not using the latest stealth/user-data-dir plugin version, as |
Yeah, thank you, I see what you mean now. Will try it tomorrow. |
Confirm with latest issue was resolved |
Hi, I raised this on the discord (https://discord.com/channels/737009125862408274/737010875960918058/900444366248763462) - but my local appears to still be hanging at this point.
to mitigate this I have followed the advice here: #421 (comment) which seems to work.
|
Describe the bug
Running puppeteer extra with user-agent-plugin causes error "Error: ENOENT: no such file or directory, stat '/tmp/puppeteer_dev_profile-6fIz4i'" visible only in DEBUG mode. Look like "puppeteer-extra-plugin:user-data-dir.onClose" called twice,
Run snippet with "DEBUG=puppeteer-extra,puppeteer-extra-plugin:* ./node_modules/.bin/ts-node ./test/script/double-close-crash.ts "
Code Snippet
Run: DEBUG=puppeteer-extra,puppeteer-extra-plugin:* ./node_modules/.bin/ts-node ./test/script/double-close-crash.ts
Versions
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
The text was updated successfully, but these errors were encountered: