puppeteer: EPERM error attempting to run example

Trying to run the following code:

var puppeteer = require("puppeteer");

puppeteer.launch().then(async browser => {
    let page = await browser.newPage();
    await page.goto('https://google.com');
    await page.screenshot({ path: 'screenshot.png' });
    browser.close();
});

I got an error:

Error: EPERM: operation not permitted, unlink 'C:\Users\tivac\Desktop\puppeteer-testing\node_modules\puppeteer\.dev_profile1\CrashpadMetrics-active.pma'

In the course of debugging this set DEBUG=* to try and understand where things were failing, but after doing that it then worked fine. 😕

Does the first-run experience not quite work right in non-DEBUG modes? I’m not sure, but that’s what happened for me!

  • puppeteer@0.9.0
  • npm@5.3.0
  • node@8.2.1
  • Windows 10 Version 1607 (OS Build 14393.1593)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 9
  • Comments: 63 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I have a solution, you have to close the page before closing the browser. Of course if you have more pages open, close all of them. await page.close(); await browser.close();

Was having an issue with await browser.close() but thanks to @ivangergo3’s answer adding a couple lines to close all the pages gets rid of the crash error! 😄

let pages = await browser.pages()
await Promise.all(pages.map(page =>page.close()))
await browser.close()

Edit 12/17/2020

  • fixed missing parentheses mentioned below
let pages = await browser.pages()
await Promise.all(pages.map(page =>page.close())
await browser.close()

let pages = await browser.pages() await Promise.all(pages.map(page =>page.close())) //one closing bracket is missing in the above code await browser.close()

I am closing all the pages before closing browser, but still seeing this issue. Anyone else the same?

I’m getting this on 5.3.1 as well.

I have a solution, you have to close the page before closing the browser. Of course if you have more pages open, close all of them. await page.close(); await browser.close();

I started getting this error on a Windows box but it was after other changes I made trying to get puppeteer to run in a Debian VM. One of the things I had to do for Debian was to add ‘–no-sandbox’, ‘–disable-setuid-sandbox’ arguments. Once I removed those, it started working on Windows again.

I forget the exact reason I had needed to add them to for Debian.

Closing all browser pages before invoking close() worked for me (thanks @ CreativeBuilds)

const pages = await browser.pages();
await Promise.all(pages.map(page => page.close()));
await browser.close();

Hello, Neither closing all pages before closing browser or using browser.process().kill('SIGKILL'); is working for me. The issue occurs randomly.

The workaround isn’t working for me, I believe the reproduction of this bug is dependent on how fast the computer is. This is my repro, gets the EPERM after 1-5 loops:

const puppeteer = require('puppeteer');
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
(async () => {
	while (true) {
		console.log('launching');
		const browser = await puppeteer.launch({ headless: false, args: ['--no-sandbox'] });
		console.log('sleeping');
		await sleep(1000);
		console.log('closing pages');
		await Promise.all((await browser.pages()).map(async page => await page.close()));
		console.log('closing');
		await browser.close();
		console.log('sleeping');
		await sleep(1000);
	}
})();

I believe the headless: false, --no-sandbox, closing each page, and also the console.logs, all make the entire thing somehow slower in the right places, and cause the crashpad process to stay alive long enough so that rimrafs timeouts and throws the error (about 600ms).

A possible solution (which is bad but works) is to increase rimrafs maxBusyTries option so that it would retry a bit more, eventually it works. A better solution is to disable the crashpad process - #2778.

Seeing this on 5.3.1 as well

I started getting this error on a Windows box but it was after other changes I made trying to get puppeteer to run in a Debian VM. One of the things I had to do for Debian was to add ‘–no-sandbox’, ‘–disable-setuid-sandbox’ arguments. Once I removed those, it started working on Windows again.

I forget the exact reason I had needed to add them to for Debian.

I had the exact same situation and this seems to have worked for me

Hello guys, just had this error in the latest version, in my case it was because I forgot an “await” before a “browser.close()”. So you should close the browser like this :

await browser.close()

My await was already missing before, but It didn’t show any error before I installed my project on another computer. So make sure not to forget your awaits just like me 😛

EDIT : Nevermind, it happens randomly even after making sure the await is there. And The issue started appearing on other projects that were fine before.

Same Problem here. [Error: EPERM: operation not permitted, unlink ‘C:\Users\xxxxxx\AppData\Local\Temp\1\puppeteer_dev_chrome_profile-sj0wiy\CrashpadMetrics-active.pma’] { errno: -4048, code: ‘EPERM’, syscall: ‘unlink’, path: ‘C:\Users\xxxxxxx\AppData\Local\Temp\1\puppeteer_dev_chrome_profile-sj0wiy\CrashpadMetrics-active.pma’ } Can some one open the issue with the dev team?

I am using puppeteer to extract data and push it into a db since the data is more i subdivided the data and running multiple instances in different computers but then i am getting the same error. Please help @aslushnikov

Yes, should be fixed now.