mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: better logging for Windows CrashPad problem (#6758)
References #6123
This commit is contained in:
parent
1d0cdb352d
commit
3aa1471489
@ -61,8 +61,6 @@ if (maxListeners !== 0)
|
||||
process.setMaxListeners(Math.max(maxListeners || 0, 100));
|
||||
|
||||
export async function launchProcess(options: LaunchProcessOptions): Promise<LaunchResult> {
|
||||
const cleanup = () => removeFolders(options.tempDirectories);
|
||||
|
||||
const stdio: ('ignore' | 'pipe')[] = options.stdio === 'pipe' ? ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'] : ['pipe', 'pipe', 'pipe'];
|
||||
options.log(`<launching> ${options.executablePath} ${options.args.join(' ')}`);
|
||||
const spawnedProcess = childProcess.spawn(
|
||||
@ -79,6 +77,16 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun
|
||||
}
|
||||
);
|
||||
|
||||
const cleanup = async () => {
|
||||
options.log(`[pid=${spawnedProcess.pid || 'N/A'}] starting temporary directories cleanup`);
|
||||
const errors = await removeFolders(options.tempDirectories);
|
||||
for (let i = 0; i < options.tempDirectories.length; ++i) {
|
||||
if (errors[i])
|
||||
options.log(`[pid=${spawnedProcess.pid || 'N/A'}] exception while removing ${options.tempDirectories[i]}: ${errors[i]}`);
|
||||
}
|
||||
options.log(`[pid=${spawnedProcess.pid || 'N/A'}] finished temporary directories cleanup`);
|
||||
};
|
||||
|
||||
// Prevent Unhandled 'error' event.
|
||||
spawnedProcess.on('error', () => {});
|
||||
|
||||
|
||||
@ -154,13 +154,11 @@ export function createGuid(): string {
|
||||
return crypto.randomBytes(16).toString('hex');
|
||||
}
|
||||
|
||||
export async function removeFolders(dirs: string[]) {
|
||||
await Promise.all(dirs.map((dir: string) => {
|
||||
return new Promise<void>(fulfill => {
|
||||
export async function removeFolders(dirs: string[]): Promise<Array<Error|undefined>> {
|
||||
return await Promise.all(dirs.map((dir: string) => {
|
||||
return new Promise<Error|undefined>(fulfill => {
|
||||
removeFolder(dir, { maxBusyTries: 10 }, error => {
|
||||
if (error)
|
||||
console.error(error); // eslint-disable no-console
|
||||
fulfill();
|
||||
fulfill(error);
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user