mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: improve debugging for EBUSY errors on Windows (#9976)
Co-authored-by: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com>
This commit is contained in:
parent
8222bc01b4
commit
0b2d988cc1
@ -291,17 +291,16 @@ class Process {
|
|||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
childProcess.exec(
|
try {
|
||||||
`taskkill /pid ${this.#browserProcess.pid} /T /F`,
|
childProcess.execSync(
|
||||||
error => {
|
`taskkill /pid ${this.#browserProcess.pid} /T /F`
|
||||||
if (error) {
|
);
|
||||||
// taskkill can fail to kill the process e.g. due to missing permissions.
|
} catch (error) {
|
||||||
// Let's kill the process via Node API. This delays killing of all child
|
// taskkill can fail to kill the process e.g. due to missing permissions.
|
||||||
// processes of `this.proc` until the main Node.js process dies.
|
// Let's kill the process via Node API. This delays killing of all child
|
||||||
this.#browserProcess.kill();
|
// processes of `this.proc` until the main Node.js process dies.
|
||||||
}
|
this.#browserProcess.kill();
|
||||||
}
|
}
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// on linux the process group can be killed with the group id prefixed with
|
// on linux the process group can be killed with the group id prefixed with
|
||||||
// a minus sign. The process group id is the group leader's pid.
|
// a minus sign. The process group id is the group leader's pid.
|
||||||
|
@ -90,11 +90,36 @@ describe('Chrome', () => {
|
|||||||
const process = launch({
|
const process = launch({
|
||||||
executablePath,
|
executablePath,
|
||||||
args: [
|
args: [
|
||||||
|
'--allow-pre-commit-input',
|
||||||
|
'--disable-background-networking',
|
||||||
|
'--disable-background-timer-throttling',
|
||||||
|
'--disable-backgrounding-occluded-windows',
|
||||||
|
'--disable-breakpad',
|
||||||
|
'--disable-client-side-phishing-detection',
|
||||||
|
'--disable-component-extensions-with-background-pages',
|
||||||
|
'--disable-component-update',
|
||||||
|
'--disable-default-apps',
|
||||||
|
'--disable-dev-shm-usage',
|
||||||
|
'--disable-extensions',
|
||||||
|
'--disable-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints,DialMediaRouteProvider',
|
||||||
|
'--disable-hang-monitor',
|
||||||
|
'--disable-ipc-flooding-protection',
|
||||||
|
'--disable-popup-blocking',
|
||||||
|
'--disable-prompt-on-repost',
|
||||||
|
'--disable-renderer-backgrounding',
|
||||||
|
'--disable-sync',
|
||||||
|
'--enable-automation',
|
||||||
|
'--enable-features=NetworkServiceInProcess2',
|
||||||
|
'--export-tagged-pdf',
|
||||||
|
'--force-color-profile=srgb',
|
||||||
'--headless=new',
|
'--headless=new',
|
||||||
'--use-mock-keychain',
|
'--metrics-recording-only',
|
||||||
'--disable-features=DialMediaRouteProvider',
|
'--no-first-run',
|
||||||
|
'--password-store=basic',
|
||||||
'--remote-debugging-port=9222',
|
'--remote-debugging-port=9222',
|
||||||
|
'--use-mock-keychain',
|
||||||
`--user-data-dir=${path.join(tmpDir, 'profile')}`,
|
`--user-data-dir=${path.join(tmpDir, 'profile')}`,
|
||||||
|
'about:blank',
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
const url = await process.waitForLineOutput(CDP_WEBSOCKET_ENDPOINT_REGEX);
|
const url = await process.waitForLineOutput(CDP_WEBSOCKET_ENDPOINT_REGEX);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
|
import {execSync} from 'child_process';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@ -26,6 +27,7 @@ import {
|
|||||||
Browser,
|
Browser,
|
||||||
BrowserPlatform,
|
BrowserPlatform,
|
||||||
Cache,
|
Cache,
|
||||||
|
createProfile,
|
||||||
} from '../../../lib/cjs/main.js';
|
} from '../../../lib/cjs/main.js';
|
||||||
import {testFirefoxBuildId} from '../versions.js';
|
import {testFirefoxBuildId} from '../versions.js';
|
||||||
|
|
||||||
@ -59,10 +61,37 @@ describe('Firefox', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
new Cache(tmpDir).clear();
|
try {
|
||||||
|
new Cache(tmpDir).clear();
|
||||||
|
} catch (err) {
|
||||||
|
if (os.platform() === 'win32') {
|
||||||
|
console.log(execSync('tasklist').toString('utf-8'));
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should launch a Firefox browser', async () => {
|
it('should launch a Firefox browser', async () => {
|
||||||
|
const userDataDir = path.join(tmpDir, 'profile');
|
||||||
|
function getArgs(): string[] {
|
||||||
|
const firefoxArguments = ['--no-remote'];
|
||||||
|
switch (os.platform()) {
|
||||||
|
case 'darwin':
|
||||||
|
firefoxArguments.push('--foreground');
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
firefoxArguments.push('--wait-for-browser');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
firefoxArguments.push('--profile', userDataDir);
|
||||||
|
firefoxArguments.push('--headless');
|
||||||
|
firefoxArguments.push('about:blank');
|
||||||
|
return firefoxArguments;
|
||||||
|
}
|
||||||
|
await createProfile(Browser.FIREFOX, {
|
||||||
|
path: userDataDir,
|
||||||
|
preferences: {},
|
||||||
|
});
|
||||||
const executablePath = computeExecutablePath({
|
const executablePath = computeExecutablePath({
|
||||||
cacheDir: tmpDir,
|
cacheDir: tmpDir,
|
||||||
browser: Browser.FIREFOX,
|
browser: Browser.FIREFOX,
|
||||||
@ -70,7 +99,7 @@ describe('Firefox', () => {
|
|||||||
});
|
});
|
||||||
const process = launch({
|
const process = launch({
|
||||||
executablePath,
|
executablePath,
|
||||||
args: [`--user-data-dir=${path.join(tmpDir, 'profile')}`],
|
args: getArgs(),
|
||||||
});
|
});
|
||||||
await process.close();
|
await process.close();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user