TypeError: Cannot read properties of undefined (reading 'node') in Cloudflare with AssemblyAI SDK
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:
- Deploy the above code in a Cloudflare Worker.
- Set the
ASSEMBLY_AI_KEYsecret. - 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!
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.
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.