Skip to content
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

Direct call to process.env in Abstract Client #349

Open
mattkenefick opened this issue Dec 10, 2024 · 1 comment
Open

Direct call to process.env in Abstract Client #349

mattkenefick opened this issue Dec 10, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mattkenefick
Copy link

What is the current behavior?

Direct calls to the global process object looking for an API key in the AbstractClient

Steps to reproduce

Run it in an environment without process

Expected behavior

Gracefully ignore the process object if it does not exist.

Please tell us about your environment

I've included @deepgram/sdk into a TypeScript SDK that compiles out for web and node environments. When using the SDK in a web environment, the app throws an error because process.env doesn't exist; I'd imagine you'd run into that for import.meta environments as well, like Vite.

Other information

I added a polyfill for it in my sdk for the time being.

(() => {
	const globalScope: any = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : {};

	if (!globalScope.process) {
		globalScope.process = {};
	}

	if (!globalScope.process.env) {
		globalScope.process.env = {};
	}
})();
@lukeocodes lukeocodes added the bug Something isn't working label Dec 30, 2024
@lukeocodes lukeocodes self-assigned this Dec 30, 2024
@lukeocodes
Copy link
Contributor

Good catch, surprised this got through...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants