-
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.
use async, respecting the function decl itself
- Loading branch information
Showing
2 changed files
with
11 additions
and
4 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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
declare global { | ||
// eslint-disable-next-line no-var | ||
var curve_bn128: {terminate: () => void} | undefined; | ||
var curve_bn128: {terminate: () => Promise<void>} | undefined; | ||
} | ||
|
||
export function teardown() { | ||
if (globalThis.curve_bn128) globalThis.curve_bn128.terminate(); | ||
/** | ||
* 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(); | ||
} |