kkoooqq / fakebrowser

🤖 Fake fingerprints to bypass anti-bot systems. Simulate mouse and keyboard operations to make behavior like a real person.
GNU Lesser General Public License v3.0
1.13k stars 211 forks source link

Modify shutdown order #59

Open davecardwell opened 2 years ago

davecardwell commented 2 years ago

puppeteer v14.1.1 on macOS 12.4 M1 Pro

Saw the error below when calling fakeBrowser.shutdown(), caused by the puppeteer’s BrowserRunner code trying to kill the process group when FakeBrowser had already killed all its PIDs.

This commit changes the order to call browser.close() before killing the process tree. You may also choose to simply remove the process killing code since puppeteer already does that.

Unhandled Rejection at: Promise {
  <rejected> Error: Puppeteer was unable to kill the process which ran the browser binary.
  This means that, on future Puppeteer launches, Puppeteer might not be able to launch the browser.
  Please check your open processes and ensure that the browser processes that Puppeteer launched have been killed.
  If you think this is a bug, please report it on the Puppeteer issue tracker.
  Error cause: Error: kill EPERM
      at process.kill (node:internal/process/per_thread:220:13)
      at BrowserRunner.kill (<removed>/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:196:29)
      at <removed>/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:168:22
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at BrowserRunner.kill (<removed>/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:200:23)
      at <removed>/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:168:22
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
}