Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: better logging for Windows CrashPad problem (#6758)

Andrey Lushnikov3aa1471489c2
diff --git a/src/server/processLauncher.ts b/src/server/processLauncher.ts
index 6262b6194d..a8939be2bc 100644
--- a/src/server/processLauncher.ts
+++ b/src/server/processLauncher.ts
@@ -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', () => {});
diff --git a/src/utils/utils.ts b/src/utils/utils.ts
index 919ec8604b..5de864c371 100644
--- a/src/utils/utils.ts
+++ b/src/utils/utils.ts
@@ -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);
});
});
}));