Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Do not clean up bb files on err #7985

Merged
merged 1 commit into from
Aug 14, 2024
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
Loading