knowledge_seeker
knowledge_seeker

Reputation: 937

Error: EPERM: operation not permitted while running puppeteer JavaScript node

I have a script which scrapes through several URLs in an infinite loop and notifies me of any changes to the website. Every time I leave it running for a while, I come back to find that it has completed tens/hundreds of iterations of the loop, but I eventually this error.

[Error: EPERM: operation not permitted, unlink 'C:\Users\user\AppData\Local\Temp\puppeteer_dev_chrome_profile-3thzgE\CrashpadMetrics-active.pma'] {
  errno: -4048,
  code: 'EPERM',
  syscall: 'unlink',
  path: 'C:\\Users\\user\\AppData\\Local\\Temp\\puppeteer_dev_chrome_profile-3thzgE\\CrashpadMetrics-active.pma'
}

This error does not appear to happen on a particular line, because as mentioned the script has been through several complete iterations of the loop before getting this error.

I googled this error, but it seems that people are only really experiencing it with NPM or if they do experience it with puppeteer it is on a particular line of their code. When I read the .pma file using an online .pma reader this is the message I got:

 CrashpadMetrics UMA.PersistentAllocator.CrashpadMetrics.UsedPct UMA.PersistentAllocator.CrashpadMetrics.Errors Crashpad.HandlerLifetimeMilestone Stability.BrowserExitCodes

Upvotes: 3

Views: 5364

Answers (2)

Edwin Miranda
Edwin Miranda

Reputation: 59

For me worked doing this

While this is annoying behaviour, there is a workaround: close all pages before closing the browser

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

https://www.gitmemory.com/issue/puppeteer/puppeteer/6563/739149056

Upvotes: 4

Andris
Andris

Reputation: 5420

If you're running this on Windows to me in a similar situation the solution was to add the node process to the exclusion list of Windows Security. I think it's preventing access to some temp file and node fails on that.

Upvotes: 3

Related Questions