o1-labs / o1js

TypeScript framework for zk-SNARKs and zkApps
https://docs.minaprotocol.com/en/zkapps/how-to-write-a-zkapp
Apache License 2.0
473 stars 105 forks source link

TypeError: workersReadyResolve is not a function error while compiling #1651

Open dfstio opened 1 month ago

dfstio commented 1 month ago

I have seen many times errors while compiling different contracts in the same worker:

Error in task TypeError: workersReadyResolve is not a function
    at startWorkers (o1js/dist/node/index.cjs:3741:3)
    at async initThreadPool (o1js/dist/node/index.cjs:3711:3)
    at async withThreadPool (o1js/dist/node/index.cjs:3678:3)
    at async prettifyStacktracePromise (o1js/dist/node/index.cjs:1934:12)
    at async compileProgram (o1js/dist/node/index.cjs:9689:60)
    at async Object.compile (o1js/dist/node/index.cjs:9520:67)

Sometimes the worker hangs out while compiling. To reproduce this effect, the worker should run for several hours and compile few different contracts. The workers I use have 10240 MB of memory.

dfstio commented 1 month ago

Maybe it happens because wasm errors occur and are not being handled https://github.com/o1-labs/o1js-bindings/blob/main/js/node/node-backend.js#L85-L90

dfstio commented 1 month ago

I was able to get rid of this error by having dedicated workers for Devnet and Zeko. Seems like the problem was in calling in the same worker first Mina.setActiveInstance for Devnet, then Mina.setActiveInstance for Zeko, then Mina.setActiveInstance for Devnet again etc.

@mitschabaude should Mina.setActiveInstance clean static variables and global state when it is being called?