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 {
|
||||
if (process.platform === 'win32') {
|
||||
childProcess.exec(
|
||||
`taskkill /pid ${this.#browserProcess.pid} /T /F`,
|
||||
error => {
|
||||
if (error) {
|
||||
try {
|
||||
childProcess.execSync(
|
||||
`taskkill /pid ${this.#browserProcess.pid} /T /F`
|
||||
);
|
||||
} catch (error) {
|
||||
// taskkill can fail to kill the process e.g. due to missing permissions.
|
||||
// Let's kill the process via Node API. This delays killing of all child
|
||||
// processes of `this.proc` until the main Node.js process dies.
|
||||
this.#browserProcess.kill();
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
// 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.
|
||||
|
@ -90,11 +90,36 @@ describe('Chrome', () => {
|
||||
const process = launch({
|
||||
executablePath,
|
||||
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',
|
||||
'--use-mock-keychain',
|
||||
'--disable-features=DialMediaRouteProvider',
|
||||
'--metrics-recording-only',
|
||||
'--no-first-run',
|
||||
'--password-store=basic',
|
||||
'--remote-debugging-port=9222',
|
||||
'--use-mock-keychain',
|
||||
`--user-data-dir=${path.join(tmpDir, 'profile')}`,
|
||||
'about:blank',
|
||||
],
|
||||
});
|
||||
const url = await process.waitForLineOutput(CDP_WEBSOCKET_ENDPOINT_REGEX);
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import assert from 'assert';
|
||||
import {execSync} from 'child_process';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@ -26,6 +27,7 @@ import {
|
||||
Browser,
|
||||
BrowserPlatform,
|
||||
Cache,
|
||||
createProfile,
|
||||
} from '../../../lib/cjs/main.js';
|
||||
import {testFirefoxBuildId} from '../versions.js';
|
||||
|
||||
@ -59,10 +61,37 @@ describe('Firefox', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
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 () => {
|
||||
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({
|
||||
cacheDir: tmpDir,
|
||||
browser: Browser.FIREFOX,
|
||||
@ -70,7 +99,7 @@ describe('Firefox', () => {
|
||||
});
|
||||
const process = launch({
|
||||
executablePath,
|
||||
args: [`--user-data-dir=${path.join(tmpDir, 'profile')}`],
|
||||
args: getArgs(),
|
||||
});
|
||||
await process.close();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user