12 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
'crypto' is part of the Convex runtime, yet it seems I still need to use
'use node'
? Further, that also doesn't seem to work, as I get the error above. I really don't want to have to create an action
just to turn a string into a number – feels like the right thing for a plain old function.
I've tried:
- adding .nobundle.ts
to the filename
- using crypto
and node:crypto
- adding "use node";
everywhere that uses this
I just want to make a string a number 😭
Switching to subtleCrypto
I'm not getting the errors anymore:
Still unsure how to use the available runtime libraries without using it in an action, and/or why subtle crypto works but cryto doesn't.Still errors. Not sure where to go from here.

Any chance "use node" has to be first, before the comments? Can't think of any other reason why it would be ignored like that
I import from node:crypto in a project and it does work
Thanks @erquhart 🙂 I tried both ways! I have noticed sometimes comments in the "wrong" place can mess with the parser (e.g. an entire that is commented out can still throw syntax/TS errors).
However, I ended up just biting the bullet and making it an action on its own. I don't love the idea that I'm firing off a full function call just to convert a string to a number, but that's where I'm at:
I call this via:
And I call that from two utility functions (one parallel and one sequential):
I know for a fact subtle crypto works in the Convex runtime
Really odd that you're getting an error for that
The better auth component depends on it
Then you can "namespace" each queue up to the number of queue's you've defined:
I know for a fact subtle crypto works in the Convex runtimeDo I need to import anything for that? It compiled fine, but failed with "module not found" when I tried to actually use it (FWIW this last approach is functioning well)
You don't need to import crypto, it's global in the convex runtime
But yeah maybe just take the win if it's working lol.
I'll bug Ian when he's back from PTO. Thanks as always @erquhart I appreciate you!
@Tom Redman FYI, it works correctly for me when you don't do the import:
Instead of:
which causes a bug, you need to use directly
createHash
in your code without the import:
Thank you! Will try this.
up on that issue
with use:node it works fine tho!