[Bug] puppeteer-extra-plugin:user-data-dir.onClose called twice and causes Error. Also possible memory leak with Plugins
See original GitHub issueDescribe 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
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 main() {
const browser = await puppeteer.launch({headless: true});
console.log('Start');
await browser.close();
console.log('Done');
})();
Run: DEBUG=puppeteer-extra,puppeteer-extra-plugin:* ./node_modules/.bin/ts-node ./test/script/double-close-crash.ts
puppeteer-extra-plugin:base:stealth/evasions/user-agent-override Initialized. +0ms
puppeteer-extra plugin registered stealth/evasions/user-agent-override +0ms
puppeteer-extra dependencies missing Set(1) { 'user-preferences' } +1ms
puppeteer-extra-plugin:base:user-preferences Initialized. +0ms
puppeteer-extra plugin registered user-preferences +3ms
puppeteer-extra dependencies missing Set(1) { 'user-data-dir' } +1ms
puppeteer-extra-plugin:base:user-data-dir Initialized. +0ms
puppeteer-extra-plugin:user-data-dir initialized {
deleteTemporary: true,
deleteExisting: false,
files: [],
folderPath: '/tmp',
folderPrefix: 'puppeteer_dev_profile-'
} +0ms
puppeteer-extra plugin registered user-data-dir +35ms
puppeteer-extra orderPlugins:before [
'stealth/evasions/user-agent-override',
'user-preferences',
'user-data-dir'
] +1ms
puppeteer-extra orderPlugins:after [
'stealth/evasions/user-agent-override',
'user-preferences',
'user-data-dir'
] +0ms
puppeteer-extra-plugin:user-preferences _userPrefsFromPlugins { intl: { accept_languages: 'en-US,en' } } +0ms
puppeteer-extra-plugin:user-data-dir created custom dir /tmp/puppeteer_dev_profile-6fIz4i +4ms
puppeteer-extra-plugin:user-data-dir Wrote file /tmp/puppeteer_dev_profile-6fIz4i/Default/Preferences +6ms
Start
puppeteer-extra-plugin:user-data-dir onClose +219ms
puppeteer-extra-plugin:user-data-dir removeUserDataDir +0ms
(node:507333) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
(Use `node --trace-deprecation ...` to show where the warning was created)
Done
puppeteer-extra-plugin:user-data-dir onClose +28ms
puppeteer-extra-plugin:user-data-dir removeUserDataDir +0ms
puppeteer-extra-plugin:user-data-dir Error: ENOENT: no such file or directory, stat '/tmp/puppeteer_dev_profile-6fIz4i'
puppeteer-extra-plugin:user-data-dir at Object.statSync (node:fs:1536:3)
puppeteer-extra-plugin:user-data-dir at __node_internal_ (node:internal/fs/utils:793:8)
puppeteer-extra-plugin:user-data-dir at Object.rmdirSync (node:fs:1156:15)
puppeteer-extra-plugin:user-data-dir at Plugin.deleteUserDataDir (/var/www/projects/svb-bot/node_modules/puppeteer-extra-plugin-user-data-dir/index.js:72:11)
puppeteer-extra-plugin:user-data-dir at Plugin.onClose (/var/www/projects/svb-bot/node_modules/puppeteer-extra-plugin-user-data-dir/index.js:114:12)
puppeteer-extra-plugin:user-data-dir at process.emit (node:events:394:28)
puppeteer-extra-plugin:user-data-dir at process.emit (node:domain:475:12)
puppeteer-extra-plugin:user-data-dir at process.emit (/var/www/projects/svb-bot/node_modules/@cspotcode/source-map-support/source-map-support.js:527:35) +0ms
Versions
├── puppeteer-afp@1.0.1 ├── puppeteer-extra-plugin-adblocker@2.11.11 ├── puppeteer-extra-plugin-block-resources@2.2.9 ├── puppeteer-extra-plugin-proxy@1.0.2 ├── puppeteer-extra-plugin-stealth@2.7.8 ├── puppeteer-extra@3.1.18 ├── puppeteer@10.2.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (3 by maintainers)
Top GitHub Comments
Confirm with latest issue was resolved
Yeah, thank you, I see what you mean now. Will try it tomorrow. I wonder if continue supporting onClose in PuppeteerExtraPlugin makes sense as it still lead to hidden memory issue in any custom outdated Plugins