Crypto not found
I'm running a Solid Start app using bun and sst, however I get this error in my console:
ERROR crypto is not defined Better Auth
I have absolutely no idea why this happening, i got it working for a moment, but it reappeared now.
23 Replies
are you on latest?
Hey @bekacru, I am getting this error now in Node 18 & 20.
But this crypto issue does not appear if I run the server with Deno
https://github.com/jacksonkasi1/better-auth-example
GitHub
GitHub - jacksonkasi1/better-auth-example
Contribute to jacksonkasi1/better-auth-example development by creating an account on GitHub.

yeah latest bun and latest better auth
can you check if this is still the case on latest
I still get the error but at a different place, before when clicking register without emai / password it just didnt respond and said crypto is missing, now I get invalid email, password is to short
but when i enter normal credentials it gives the same error
ERROR crypto is not defined Better Auth
at Object.ke [as hash] (node_modules/better-auth/dist/index.js:1:823)
at node_modules/better-auth/dist/index.js:83:1562
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async handle (node_modules/better-auth/node_modules/better-call/dist/index.js:374:17)
at async a.<computed> (node_modules/better-auth/dist/index.js:83:5818)
at async handler (node_modules/better-auth/node_modules/better-call/dist/index.js:588:26)
at async handler (node_modules/better-auth/node_modules/better-call/dist/index.js:639:19)
at async eval (/home/notluksus/dev/sodefa/graphrag-demo/node_modules/@solidjs/start/dist/server/handler.js:38:23)
at async _callHandler (/home/notluksus/dev/sodefa/graphrag-demo/node_modules/h3/dist/index.mjs:1821:16)
This is the stack trace
could you try the it on next
pnpm i
better-auth@next
yeah works
Nvm still the error
It somewhat worked with the previous version, there it created a user in the database but not account. Then I tried to register for that email again, it failed because the email exists, i remove the user. I registered again and now its broken
is the error still crypto not found?
yes
also im using bun, probably shouldnt matter, just fyi
This seems to be a solid start issue, when using the global crypto namespace it breaks
Yeah got that. I’ve switched to the imported crypto module, so it should have been fixed. I’ll check later why it is still happening.
Thank you, keep me posted please!
check for me if it's fixed on next
if not please send me the stack trace
works :)
Ok turns out that now registering and so on works, however the password isn't set
Password not found { email: 'XXX' }
The account in drizzle also has an empty password column

hmm can you pass custom
verify
and hash
password
you can use Bun's builtin password hasher
in the auth config emailAndPassword.password
one sec
i'm even more confused now, it turns out that when using sst, even if im in a bun monorepo / project, it runs node
So since it isnt running bun i used bcrypt:
Password field is stay empty
No idea. If possible, create a public repo so I can reproduce it on my end.
does the session get created?
yeah it does
yeah let me try to get a reproduction
GitHub
GitHub - NotLuksus/better-auth-repro
Contribute to NotLuksus/better-auth-repro development by creating an account on GitHub.
pnpm install, set env, start a local postgres
docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
, pnpm dev inside the web package, signup, check account using drizzle studio, account password should be empty, signout, try to sign back in again, no password found error
I removed the sst part for simplicity as it doesnt really add much to the case here anywaythanks. I'll take a look.
I just found the issue: the
password
field was named passwordHash
in your Drizzle schema. It doesn't matter what it maps to in the database, Drizzle will ignore the password
field.omg, thank you, what a stupid mistake!
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View