semaphore
semaphore copied to clipboard
verifyProof hangs in node.js environment
Describe the bug I have a backend service that receives a proof from a frontend to verify it. It never finishes running the verifyProof function.
Verifying on frontend works as expected.
To Reproduce Steps to reproduce the behavior:
- Create proof in a browser
- Send to a Next.js server
verifyProof(proof)- Nothing happens
Expected behavior Expecting verifyProof to return true or false in nodejs environment.
Technologies (please complete the following information):
- Node.js version 20.9.0
- NPM version 10.1.0
- Semaphore 4.0.0-beta.1
- Solidity version N/A
Additional context Using it in Next.js and bun.
Link to repo:
- https://github.com/carlbarrdahl/squarevote/pull/1
Hey! Semaphore does not work with Bun. You can take a look at this: https://github.com/vplasencia/semaphore-bun
Regarding Nextjs and node, did you try other package manager like npm, yarn or pnpm? Is it working?
Hey! Semaphore does not work with Bun. You can take a look at this: https://github.com/vplasencia/semaphore-bun
Regarding Nextjs and node, did you try other package manager like npm, yarn or pnpm? Is it working?
I tried both npm run dev as well as building the project and then next start (via npm).
Still hangs at verifying proof.
I was able to get it working easily in an isolated environment with bun init and then running the code with npx tsx index.ts.
After some more testing it seems it works with npm run build && npm run start (but npm run dev doesn't).
I created a minimal repo here with create-next-app:
https://github.com/carlbarrdahl/next-semaphore https://replit.com/@CarlBarrdahl/next-semaphore
Relevant files: https://github.com/carlbarrdahl/next-semaphore/blob/49643e0b563170b164aaf8098ae109c4bf4c5d33/components/ZkProof.tsx#L7-L20 https://github.com/carlbarrdahl/next-semaphore/blob/49643e0b563170b164aaf8098ae109c4bf4c5d33/app/api/route.ts#L5-L10
Hey @carlbarrdahl
Thank you so much for the information and code. It's very interesting that it works with npm run build && npm run start and not with npm run dev.
It seems that Semaphore v3 and v4 don't work with Nextjs 14 with the app folder. Semaphore v3 is working with Nextjs 13 with pages (this is an example of project: https://github.com/bandada-infra/bandada-semaphore-demo). Semaphore v4 is not working with Nextjs 13 because of this issue we are trying to solve: https://github.com/semaphore-protocol/semaphore/issues/713
Great to hear you've identified the bug and tracking it!
Hey @carlbarrdahl
Regarding the issue https://github.com/semaphore-protocol/semaphore/issues/713 I mentioned before, one quick fix for now could be to use resolutions with yarn or overrides with npm inside your project.