简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM