assemblyai-node-sdk icon indicating copy to clipboard operation
assemblyai-node-sdk copied to clipboard

TypeError: Cannot read properties of undefined (reading 'node') in Cloudflare with AssemblyAI SDK

Open vricale opened this issue 1 year ago • 2 comments

Description:
When using the AssemblyAI Node SDK in a Cloudflare Worker, I encounter the following error:

TypeError: Cannot read properties of undefined (reading 'node')

Code Snippet:

const { AssemblyAI } = await import('assemblyai');

const client = new AssemblyAI({
  apiKey: getSecret('ASSEMBLY_AI_KEY'),
});

const transcript = await client.transcripts.get(transcriptionId);

Environment:

  • Platform: Cloudflare Workers
  • SDK Version: latest

Steps to Reproduce:

  1. Deploy the above code in a Cloudflare Worker.
  2. Set the ASSEMBLY_AI_KEY secret.
  3. Call the function with a valid transcriptionId.

Expected:
Successfully retrieve the transcript.

Actual:
Error in Cloudflare logs:

TypeError: Cannot read properties of undefined (reading 'node')

Notes:

  • Works correctly in a local Node.js environment.
  • Verified API key and permissions.
  • Tried both CommonJS and ES Module imports without success.

Request:
Assistance in resolving this issue or guidance on using AssemblyAI SDK with Cloudflare Workers.

Thank you!

vricale avatar Jan 09 '25 07:01 vricale

Cloudflare workers runtime isn't node. This package seems to require node specifically. I am running into the same error when running in a Convex function, which runs in a runtime compatible with cloudflare workers. I don't really understand why this package cannot run in other runtimes aside from node.

warmbowski avatar May 09 '25 04:05 warmbowski

I’m having the same issue. And the alternative https://ai-sdk.dev/providers/ai-sdk-providers/assemblyai is a half-baked cook because you can’t retrieve the transcript when using the webhook url.

Antoine4011 avatar Jun 16 '25 18:06 Antoine4011