Unable to run livekit-server-sdk in Convex default runtime

v2 moved to using web crypto but there is still import(‘node:crypto’) somewhere which doesn’t allow running in Convex’s default cf-workers like v8 isolate runtime and i need to use the slower ‘use node’ runtime. I just want to use the lightweight RoomServiceClient, from what I understand LiveKit wants to make it edge compatible in non-node runtimes like workers and others natively.

I believe the fix might be very simple: As node:crypto is only being used as backup if web crypto isn’t available, so making it so that bundler doesn’t conflict.

From agent:
On using livekit-server-sdk@2.17.0 on Convex’s default action runtime (V8 isolate, CF Workers–like: has fetch + Web Crypto, no Node builtins).

The SDK is clearly meant to be isomorphic (Web Crypto first, jose, edge/browser tests in the package). At runtime that works: globalThis.crypto.subtle is present, so digest / uuid would take the Web Crypto branch.

But at bundle time Convex fails with something like:

Could not resolve “node:crypto”

…because these still ship a Node fallback:

  • packages/livekit-server-sdk/src/crypto/digest.tsawait import('node:crypto')
  • packages/livekit-server-sdk/src/crypto/uuid.ts → same

Isolate bundlers (Convex default runtime, and often Workers without Node compat) resolve that dynamic import even when it’s in an else branch that never runs.

Consider one of:

  1. A pure-web / edge export condition that omits the node:crypto fallback entirely, or
  2. Dropping the Node fallback (Node 18+ has global Web Crypto anyway), or
  3. Making the fallback injectable / compile-time stripped so edge bundlers don’t see node:crypto

Hey @darryncampbell, I am using LiveKit cloud, not self-hosting, you have changed the category to self-hosting. The runtime talk here is for backend where livekit-server-sdk runs. The change required is indeed for the Server SDK.

By the way I just found out that this exact issue was fixed cleanly in PR#122 but issue was reintroduced directly in PR#349 which was 2 years ago and is legacy fix now and can be dropped to support modern edge and serverless runtimes.

The solution is just a 2 line fix in livekit-server-sdk/src/crypto/uuid.ts and livekit-server-sdk/src/crypto/digest.ts which does:

I have opened a pull request for it: PR#704

@PodoTip Sorry about that, and thank you for raising the PR. If it doesn’t get any traction please @ me and I’ll follow up.