mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(Launcher): Launcher should handle chrome process errors (#863)
Fixes #750
This commit is contained in:
parent
cb280c526d
commit
c46c41d89c
@ -116,16 +116,13 @@ class Launcher {
|
||||
*/
|
||||
function killChrome() {
|
||||
helper.removeEventListeners(listeners);
|
||||
if (chromeProcess.pid) {
|
||||
if (temporaryUserDataDir) {
|
||||
// Force kill chrome.
|
||||
if (process.platform === 'win32')
|
||||
childProcess.execSync(`taskkill /pid ${chromeProcess.pid} /T /F`);
|
||||
else
|
||||
process.kill(-chromeProcess.pid, 'SIGKILL');
|
||||
// Attempt to remove temporary profile directory to avoid littering.
|
||||
try {
|
||||
removeSync(temporaryUserDataDir);
|
||||
} catch (e) { }
|
||||
} else {
|
||||
// Terminate chrome gracefully.
|
||||
if (process.platform === 'win32')
|
||||
@ -133,6 +130,13 @@ class Launcher {
|
||||
else
|
||||
process.kill(-chromeProcess.pid, 'SIGTERM');
|
||||
}
|
||||
}
|
||||
if (temporaryUserDataDir) {
|
||||
// Attempt to remove temporary profile directory to avoid littering.
|
||||
try {
|
||||
removeSync(temporaryUserDataDir);
|
||||
} catch (e) { }
|
||||
}
|
||||
return waitForChromeToClose;
|
||||
}
|
||||
}
|
||||
@ -166,15 +170,19 @@ function waitForWSEndpoint(chromeProcess, timeout) {
|
||||
let stderr = '';
|
||||
const listeners = [
|
||||
helper.addEventListener(rl, 'line', onLine),
|
||||
helper.addEventListener(rl, 'close', onClose),
|
||||
helper.addEventListener(chromeProcess, 'exit', onClose)
|
||||
helper.addEventListener(rl, 'close', () => onClose()),
|
||||
helper.addEventListener(chromeProcess, 'exit', () => onClose()),
|
||||
helper.addEventListener(chromeProcess, 'error', error => onClose(error))
|
||||
];
|
||||
const timeoutId = timeout ? setTimeout(onTimeout, timeout) : 0;
|
||||
|
||||
function onClose() {
|
||||
/**
|
||||
* @param {!Error=} error
|
||||
*/
|
||||
function onClose(error) {
|
||||
cleanup();
|
||||
reject(new Error([
|
||||
'Failed to launch chrome!',
|
||||
'Failed to launch chrome!' + (error ? ' ' + error.message : ''),
|
||||
stderr,
|
||||
'',
|
||||
'TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md',
|
||||
|
Loading…
Reference in New Issue
Block a user