deepgram / deepgram-js-sdk

Official JavaScript SDK for Deepgram's automated speech recognition APIs.
https://developers.deepgram.com
MIT License
127 stars 45 forks source link

v3.3.0 Error in the browser: `Uncaught ReferenceError: process is not defined` #274

Closed shashank1010 closed 1 month ago

shashank1010 commented 1 month ago

What is the current behavior?

Installing v3.3.0 results in the error Uncaught ReferenceError: process is not defined

What's happening that seems wrong?

It seems that the dist bundle is not correct. dist bundles should have references to process object

Steps to reproduce

  1. Install deepgram-sdk and use it in a browser application
  2. Run the application
  3. Visit the webpage

Expected behavior

  1. The application should simply run
  2. And you can use the deepgram client.

Please tell us about your environment

Other information

Reverting to v3.2.0 resolves the issue.

Anything else we should know? (e.g. detailed explanation, stack-traces, related issues, suggestions how to fix, links for us to have context, eg. stack overflow, codepen, etc)

  1. deepgram v3.2 Example: https://stackblitz.com/edit/vitejs-vite-fhctlf?file=package.json (This works fine)
  2. deepgram v3.3 Example: https://stackblitz.com/edit/vitejs-vite-zg6vpu?file=package.json (This fails)
image
lukeocodes commented 1 month ago

Ahh we've introduced a regression. I will fix this today hopefully.

shashank1010 commented 1 month ago

The issue response time there was off the charts! Really appreciate it!! Kudos!

Thanks.

youcefs21 commented 1 month ago

doesn't seem to be fixed? CleanShot 2024-05-01 at 12 26 04@2x

lukeocodes commented 1 month ago

doesn't seem to be fixed? CleanShot 2024-05-01 at 12 26 04@2x

Your IDE is configured for browser environment, and not Node. A Webpack plugin will provide a static value to the property notation process.node.version in the browser.

IDE squiggles are not bugs

lukeocodes commented 1 month ago

The issue response time there was off the charts! Really appreciate it!! Kudos!

Thanks.

Oh you're welcome! Just had a free moment and that error is a familiar problem hehe

youcefs21 commented 1 month ago

Your IDE is configured for browser environment, and not Node. A Webpack plugin will provide a static value to the property notation process.node.version in the browser.

IDE squiggles are not bugs

This is not an IDE, this is chrome dev tools, it's a browser. I'll investigate more, might be a bun bug

edit: not a bun bug, same problem with yarn

https://github.com/deepgram/deepgram-js-sdk/assets/34604972/2b13a934-762a-4d0b-8856-a9363c61cf86

could it be a cache issue? something else?

alabhyajindal commented 1 month ago

Hi! I'm facing the same issue right now. I have a SvelteKit app. When I import the SDK:

<script lang="ts">
    import { createClient } from '@deepgram/sdk';
</script>

I get the following error: image

noxan commented 1 month ago

@lukeocodes the problem persists in version 3.3.1 with vite and other environments. it did not exist in 3.2.0 yet... could we please reopen this issue?

YangVincent commented 1 month ago

Hi, I'm also getting this same issue, also with vite & sveltekit.

lukeocodes commented 1 month ago

There is a PR up by a community member to resolve this, it has comments that need addressing

noxan commented 1 month ago

@lukeocodes Yes, thanks for pointing this out I commented there. To me the problem lies deeper honestly, first you introduced the new requirement to have a process.env variable during build with a patch version release (yes, that broke our product). Secondly, it is not documented anywhere, that this is even necessary, so everyone using your sdk for the first time (unless they happen to use webpack and copy your example) will end up with this issue. Lastly, as written in the other comment, I do not understand your motivation in the first place, what's the benefit of tracing a build time nodejs version which does not have any meaning for the actual runtime of your sdk? Please make the requirement on the process.env optional again or at least document it properly and release a new version reflecting this breaking change, thanks!

Fadedrifleman commented 1 month ago

@lukeocodes HI, i just tried this on browser, this issue is still present on sdk v3.3.3, also tried sdk v3.3.1 same error

created a ticket on discord as well

lukeocodes commented 1 month ago

@lukeocodes HI, i just tried this on browser, this issue is still present on sdk v3.3.3, also tried sdk v3.3.1 same error

created a ticket on discord as well

In vite built apps?

Fadedrifleman commented 1 month ago

@lukeocodes HI, i just tried this on browser, this issue is still present on sdk v3.3.3, also tried sdk v3.3.1 same error

created a ticket on discord as well

In vite built apps?

Create react app

lukeocodes commented 1 month ago

@lukeocodes HI, i just tried this on browser, this issue is still present on sdk v3.3.3, also tried sdk v3.3.1 same error created a ticket on discord as well

In vite built apps?

Create react app

hmmm understood. we need a better solution, we see that