Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion yarn-project/bb-prover/src/prover/bb_private_kernel_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
}

private runInDirectory<T>(fn: (dir: string) => Promise<T>) {
return runInDirectory(this.bbWorkingDirectory, fn, this.skipCleanup);
const log = this.log;
return runInDirectory(
this.bbWorkingDirectory,
(dir: string) =>
fn(dir).catch(err => {
log.error(`Error running operation at ${dir}: ${err}`);
throw err;
}),
this.skipCleanup,
);
}
}
10 changes: 9 additions & 1 deletion yarn-project/bb-prover/src/prover/bb_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,14 @@ export class BBNativeRollupProver implements ServerCircuitProver {
}

private runInDirectory<T>(fn: (dir: string) => Promise<T>) {
return runInDirectory(this.config.bbWorkingDirectory, fn, this.config.bbSkipCleanup);
return runInDirectory(
this.config.bbWorkingDirectory,
(dir: string) =>
fn(dir).catch(err => {
logger.error(`Error running operation at ${dir}: ${err}`);
throw err;
}),
this.config.bbSkipCleanup,
);
}
}
5 changes: 4 additions & 1 deletion yarn-project/foundation/src/fs/run_in_dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'fs/promises';
import * as path from 'path';

// Create a random directory underneath a 'base' directory
// Calls a provided method, ensures the random directory is cleaned up afterwards
// Calls a provided method, ensures the random directory is cleaned up afterwards unless the operation fails
export async function runInDirectory<T>(
workingDirBase: string,
fn: (dir: string) => Promise<T>,
Expand All @@ -15,6 +15,9 @@ export async function runInDirectory<T>(

try {
return await fn(workingDirectory);
} catch (err) {
skipCleanup = true;
throw err;
} finally {
if (!skipCleanup) {
await fs.rm(workingDirectory, { recursive: true, force: true });
Expand Down