-
Notifications
You must be signed in to change notification settings - Fork 846
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
BrowserDetector detects Node.js v21.0.0 and later as being a browser #4561
Comments
Thoughts on using Both latest Node.js and Bun have a @MSNev Any experience or opinions here for how to identify if we are in a browser runtime? |
While I generally, go the other way around and detect whether the environment is node, see the "helpers" I have in the "Runtime Environment Checks" section of this https://github.com/nevware21/ts-utils?tab=readme-ov-file#documentation-and-details. So basically, if something "wants" to use window it uses either And likewise for the |
I think testing node environment variables should be possible to detect if we're in node. Something like |
What happened?
Steps to Reproduce
Expected Result
Tests should pass.
Actual Result
They fail one test:
Additional Details
BrowserDetectorSync
is usingconst isBrowser = typeof navigator !== 'undefined';
opentelemetry-js/packages/opentelemetry-resources/src/detectors/BrowserDetectorSync.ts
Line 27 in aabd1a9
but Node.js v21.0.0 added a global
navigator
:https://nodejs.org/api/all.html#all_globals_navigator
The text was updated successfully, but these errors were encountered: