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

"Process could not be terminated" error is thrown on Windows #178

Closed
onderceylan opened this issue Nov 5, 2019 · 4 comments · Fixed by #179
Closed

"Process could not be terminated" error is thrown on Windows #178

onderceylan opened this issue Nov 5, 2019 · 4 comments · Fixed by #179

Comments

@onderceylan
Copy link
Contributor

First of all, thanks for this awesome library! I use it together with puppeteer-core to avoid chromium installs if Chrome exists on users system, in the library that I maintain: https://github.com/onderceylan/pwa-asset-generator

I'm getting the following error on Windows, after calling chrome.kill().

ERROR: The process with PID 12345 (child process of PID 1234) could not be terminated.
Reason: There is no running instance of the task.

I see 2 issues with this;

  1. Not sure why but sometimes this error occur and sometimes not. Ideally, I hope the root cause of this can be found and fixed.

  2. Second issue is, this error is being logged to the console directly, and logLevel setting is not respected when this error is thrown. Ideally, it should be logged based on logLevel setting.

I hope it's possible to get this issue fixed. If not, I'd love to go for the second option as this issue logs an unnecessary output for my CLI lib at the moment.

@patrickhulce
Copy link
Collaborator

patrickhulce commented Nov 5, 2019

Thanks for filing!

  1. That error typically means that Chrome has already died, so there is nothing left to be killed. If you do not really care if Chrome is already dead, then you should be able to safely ignore rejections from .kill()
  2. Nice catch! It's being output directly to stderr by the taskkill command in our execSync. If anyone is interested in a PR, we should just need to throw {stdio: 'pipe'} on
    execSync(`taskkill /pid ${this.chrome.pid} /T /F`);
    (it's pipe by default but nodejs also outputs stderr to parent stderr if you don't manually specify stdio)

@onderceylan
Copy link
Contributor Author

Thanks for thorough instructions @patrickhulce. I will create a PR to improve the logging soon.

@PPInfy
Copy link

PPInfy commented Nov 14, 2019

I am getting the following error after applying your changes as well.

Error: Chrome could not be killed Command failed: taskkill /pid 10576 /T /F
ERROR: The process with PID 11820 (child process of PID 10576) could not be term
inated.
Reason: The operation attempted is not supported.

at Promise (D:\TEST\TestNPM\LatestCode\is-website-vulnerable-master\node_mod

ules\chrome-launcher\dist\chrome-launcher.js:259:28)
at new Promise ()
at Launcher.kill (D:\TEST\TestNPM\LatestCode\is-website-vulnerable-master\no
de_modules\chrome-launcher\dist\chrome-launcher.js:241:16)
at Object. (D:\TEST\TestNPM\LatestCode\is-website-vulnerable-mast
er\node_modules\chrome-launcher\dist\chrome-launcher.js:58:29)
at Generator.next ()
at D:\TEST\TestNPM\LatestCode\is-website-vulnerable-master\node_modules\chro
me-launcher\dist\chrome-launcher.js:12:71
at new Promise ()
at __awaiter (D:\TEST\TestNPM\LatestCode\is-website-vulnerable-master\node_m
odules\chrome-launcher\dist\chrome-launcher.js:8:12)
at Object.kill (D:\TEST\TestNPM\LatestCode\is-website-vulnerable-master\node
_modules\chrome-launcher\dist\chrome-launcher.js:53:28)
at Audit.scanUrl (D:\TEST\TestNPM\LatestCode\is-website-vulnerable-master\sr
c\Audit.js:81:26)

@PPInfy
Copy link

PPInfy commented Nov 14, 2019

However trying this code worked

setTimeout( () => {
execSync(taskkill /pid ${this.chrome.pid} /T /F)}
,500);

westy92 added a commit to westy92/html-pdf-chrome that referenced this issue Jun 25, 2021
westy92 added a commit to westy92/html-pdf-chrome that referenced this issue Jun 25, 2021
* First attempt at Windows builds

* Delete .appveyor.yml

* Remove AppVeyor badge.

* ignore kill result; fails on Windows.

GoogleChrome/chrome-launcher#178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants