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

References #6123
This commit is contained in:
Andrey Lushnikov 2021-05-26 10:49:38 -07:00 committed by GitHub
parent 1d0cdb352d
commit 3aa1471489
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View File

@ -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', () => {});

View File

@ -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);
});
});
}));