-
Notifications
You must be signed in to change notification settings - Fork 825
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
Cannot read properties of undefined. Reading OTEL_SDK_DISABLED #3613
Comments
Why do they set What if someone sets |
Devs, when they face issues, flock to stack overflow, and end up on threads like https://stackoverflow.com/questions/64557638/how-to-polyfill-node-core-modules-in-webpack-5 where the most voted answer tells them to set it as false.
My suggested extra cautious null check would help in sorting this out. I would recommend using
typeof process would be string. process would be this string and process.env would be undefined therefore not breaking the usual flow. If someone now puts process.env to true/random-stuff, then, anyway, not much can be done for such folks, apart from educating them about it. What is your opinion on this? |
We tend to avoid dependencies to 3rd parties even to popular ones like lodash if possible. If a falsy check solves problems I would vote for adding it. It's Javascript world here so types are not that strict. Could you create a PR for this? |
Sure. Would raise it, this week. |
@ravindra-dyte would it be okay if I assign the issue to you? 🙂 |
Sure @pichlermarc |
What happened?
Users integrating our SDK (that internally uses Opentelemetry SDK) fails to initialize with the following error
Cannot read properties of undefined. Reading OTEL_SDK_DISABLED
Steps to Reproduce
We are an SDK company, and we have integrated Opentelemetry in our SDK. Clients of ours who are having bundler configs, such as webpack config, where node integration's globals are set to false (process in this case), not undefined but false, face this issue.
This is happening because
opentelemetry-js/packages/opentelemetry-core/src/utils/environment.ts
Line 336 in 47444f2
checks for undefined only whereas the value is false for them therefore it passes the check but fails afterward when it tries to pick environment variables from process.env. Because the process is false, process.env would be undefined and any key retrieval on process.env would throw this above error.
Expected Result
The default configuration should be picked.
A falsy check should be there to ensure that the process.env is also not falsy.
For example, we could replace,
with
to not allow null, undefine, or any other falsy value.
Or we can remove node globals from browser-based SDKs.
Actual Result
It fails, treats false as an object, and fails with an error.
Additional Details
We could ask our clients to make the change in their bundler configs, but it is less than ideal. Also, it gives a poor first impression.
OpenTelemetry Setup Code
package.json
Relevant log output
No response
The text was updated successfully, but these errors were encountered: