question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] puppeteer-extra-plugin:user-data-dir.onClose called twice and causes Error. Also possible memory leak with Plugins

See original GitHub issue

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

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:closed
  • Created 2 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
stupidprcommented, Sep 21, 2021

Confirm with latest issue was resolved

 - puppeteer-extra@3.1.18
 - puppeteer-extra-plugin-stealth@2.7.9
 - puppeteer-extra-plugin-user-data-dir@2.2.13
 - puppeteer-extra-plugin-user-preferences@2.2.13
1reaction
stupidprcommented, Sep 20, 2021

But yeah, it seems like you’re not using the latest stealth/user-data-dir plugin version, as onClose has been removed and we switched to onDisconnected which should not have these issues.

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible Memory Leak / PHP Fatal Memory Error
Hello,. Since switching to Spotlight from Smash Balloon's Instagram Feed plugin a few days ago I keep getting a PHP Fatal Error that...
Read more >
4 Types of Memory Leaks in JavaScript and How to Get Rid Of ...
In this article we will explore common types of memory leaks in client-side JavaScript code. We will also learn how to use the...
Read more >
Incident report on memory leak caused by Cloudflare parser bug
The bug was serious because the leaked memory could contain private information and because it had been cached by search engines. We have...
Read more >
Find memory leaks with the CRT Library - Microsoft Learn
Memory leaks are among the most subtle and hard-to-detect bugs in C/C++ ... A leaking app that uses up all available memory can...
Read more >
3 Troubleshoot Memory Leaks - Java - Oracle Help Center
Note: The APIs that are called by an application could also be unintentionally holding object references. One other potential source of this error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found