-
Notifications
You must be signed in to change notification settings - Fork 821
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
fix(core): added falsy check to make otel core work with browser where webpack config had process as false or null #3617
Conversation
…th webpack config having process as false or null
|
Could you please add add a test to verify the use case you want to support is actually fixed? |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3617 +/- ##
==========================================
+ Coverage 93.89% 94.28% +0.39%
==========================================
Files 265 1 -264
Lines 7371 175 -7196
Branches 1497 39 -1458
==========================================
- Hits 6921 165 -6756
+ Misses 450 10 -440 |
Added the tests & changelog. Let me know if this would suffice @Flarna |
I thought more about a more direct test of |
My bad. 🤦♂️ I am used to auto-linting in the commit phase. Fixed the linting issues. |
Co-authored-by: Chengzhong Wu <[email protected]>
Merging this as the failing tests are unrelated to this PR (#3628) |
Which problem is this PR solving?
Fixes #3613
Some customers of ours are using webpack where they had set all node globals to false (https://webpack.js.org/migrate/5/), as suggested by Stack overflow responses such as https://stackoverflow.com/questions/64557638/how-to-polyfill-node-core-modules-in-webpack-5 where best voted answers suggest devs to set Node Globals as false as a fallback. Current check on
process
was doing a plain type check to see equality with undefined however typeof false is boolean & typeof null is object.To ensure that OTEL works with any config having undefined/null/false, this PR was raised.
Short description of the changes
Added falsy checks while using
process
in browser environment to ensure that the OTEL can work with projects where webpack config has process set to false/null. Refer https://stackoverflow.com/questions/64557638/how-to-polyfill-node-core-modules-in-webpack-5 to see why process is set to false/null.Type of change
How Has This Been Tested?
Created a separate file to write tests. A separate file for impact testing globals would make it expandable in the future to test out other globals such as URL, and crypto. For this new Test file, replaced the globals.process in before to test the scenario.
Before change:
(If I set globals.process to false with existing tests)
After:
Checklist: