Skip to content

Commit e53ff20

Browse files
committed
fix: correct NativeUltraHonkBackend proof handling
1 parent 3935789 commit e53ff20

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/contracts/sdk/NativeUltraHonkBackend.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class NativeUltraHonkBackend {
2828
targetDir,
2929
`${circuitHash}_${witnessHash}_proof`,
3030
);
31+
fs.mkdirSync(proofOutputPath, { recursive: true });
3132

3233
fs.writeFileSync(circuitJsonPath, JSON.stringify(this.circuit));
3334
fs.writeFileSync(witnessOutputPath, witness);
@@ -54,7 +55,7 @@ export class NativeUltraHonkBackend {
5455
console.error(`stderr: ${data}`);
5556
});
5657

57-
return await new Promise<ProofData>((resolve, reject) => {
58+
const promise = new Promise<ProofData>((resolve, reject) => {
5859
bbProcess.on("close", (code: number) => {
5960
if (code !== 0) {
6061
reject(new Error(`Process exited with code ${code}`));
@@ -67,6 +68,12 @@ export class NativeUltraHonkBackend {
6768
reject(new Error(`Failed to start process: ${err.message}`));
6869
});
6970
});
71+
try {
72+
return await promise;
73+
} finally {
74+
fs.rmSync(proofOutputPath, { recursive: true });
75+
fs.rmSync(witnessOutputPath, { recursive: true });
76+
}
7077
}
7178

7279
async #getCircuitHash() {

0 commit comments

Comments
 (0)