-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from ScreamingHawk/terminate
Add teardown to cli commands
- Loading branch information
Showing
2 changed files
with
21 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
declare global { | ||
// eslint-disable-next-line no-var | ||
var curve_bn128: {terminate: () => Promise<void>} | undefined; | ||
} | ||
|
||
/** | ||
* Teardown function to be run for graceful exits. | ||
* | ||
* SnarkJS may attach curve_bn128 to global, but does not terminate it. | ||
* We have to do it manually (see https://github.com/iden3/snarkjs/issues/152) | ||
* For this, we use the [`terminate`](https://github.com/iden3/ffjavascript/blob/master/src/bn128.js#L48) function. | ||
*/ | ||
export async function teardown() { | ||
if (globalThis.curve_bn128) await globalThis.curve_bn128.terminate(); | ||
} |