-
Notifications
You must be signed in to change notification settings - Fork 419
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
Workers keep running longer than expected #152
Comments
Which version of snarkjs is this happening on? I did work in more recent versions of ffjavascript that should have solved this. |
Thanks for the quick response! |
@Schaeff I'm still looking into this, but I did remember that ffjavascript attaches the curves to a global object. So if you are using bn128, you could do I'm on the fence if snarkjs should terminate the curves itself, since some code might do multiple operations with the same curve and we don't want to re-initialize it. Maybe we could terminate them only in the CLI or maybe behind a flag. Thoughts? |
This worked, thanks! I do not have a strong opinion, I just wanted the tests to end cleanly. Maybe documenting this detail better would be enough? This can be closed as far as I am concerned. |
This comment was marked as duplicate.
This comment was marked as duplicate.
I also had this problem with Jest and I would like to note that afterAll(async () => {
// you can @ts-ignore if you are using ts-jest or such
await globalThis.curve_bn128.terminate();
}); |
Was experiencing this exact problem and started looking at the issues. I'm glad there's a fix available, and indeed, Jest's --detectOpenHandles does not detect this! |
While using mocha to test some snarkjs setup and proof generation, the test suite ends up hanging after all tests pass.
I checked why that was the case using why-is-node-running in my
after
function and the result points to worker threads in snarkjs:In the tests to this repo I found the following:
If calling
curve.terminate()
is the solution to close the workers, is there a way to do the same thing when using, say,snarkjs.groth16.prove(zkeyPath, witnessPath)
?Apologies if I'm missing something obvious, my javascript is a bit rusty!
Cheers
The text was updated successfully, but these errors were encountered: