-
Notifications
You must be signed in to change notification settings - Fork 43
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
UnhandledSchemeError node:crypto
#344
Comments
Some extra content: Vercel Edge functions don't seem to support |
This broke deployment to Cloudflare Pages too. They don't support node:crypto. |
Same here. Vercel with edge runtime, currently with a locked posthog-node version. Awaiting the investigation. |
same here with cloudflare page and nextjs edge runtime |
i made it work by downgrading to a 1 month old version of posthog-node
|
This should work with Node 17+ and edge runtimes like cloudflare, vercel edge and bun. The library targets node 15+ but security support for that ended almost 4 years ago. async function _hash(key: string, distinctId: string, salt: string = ''): Promise<number> {
const data = new TextEncoder().encode(`${key}.${distinctId}${salt}`)
const hashBuffer = await crypto.subtle.digest('SHA-1', data)
const hashArray = Array.from(new Uint8Array(hashBuffer))
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
return parseInt(hashHex.slice(0, 15), 16) / LONG_SCALE
} |
Bug description
Error deploying to Vercel on latest
4.4.0
release. It appearsnode:crypto
was introduced in4.4.0
(#329). I have locked myposthog-node
version to4.3.0
in the meantime as a workaround.How to reproduce
posthog-node
packageRelated sub-libraries
Additional context
Thank you for your bug report – we love squashing them!
The text was updated successfully, but these errors were encountered: