PuppeteerSharp 将Html转Pdf后,后台多个Chromium instances保持活动

const browser = await puppeteer.launch({
    headless: true,
    args: ['--no-sandbox']
  })
  const browserWSEndpoint = await browser.wsEndpoint()

结束后,后台保留多个Chromium instances活动,占用资源

 

-------------------------------------------------------------------------------------------------------------

解决方案是:修改puppeteer.launch的args参数

const browser = await puppeteer.launch({
    headless: true,
    args: ['--single-process', '--no-zygote', '--no-sandbox']
  })
  const browserWSEndpoint = await browser.wsEndpoint()


添加参数:
  • -single-process

  • --no-zygote

--------------------------------------------------------------------------------------------------------------

经测试有效,资料来源:https://www.it1352.com/1996175.html

posted @ 2021-03-26 09:04  fengdong  阅读(112)  评论(0)    收藏  举报