Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify shutdown order #59

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

davecardwell
Copy link

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)
}

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](https://github.com/puppeteer/puppeteer/blob/256223a7b18672ae3890bde312986482ea0fed52/src/node/BrowserRunner.ts#L182-L220).

```
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)
}
```
src/core/Driver.ts Outdated Show resolved Hide resolved
Co-authored-by: BEAR <RubtsovAV@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants