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

IS_BROWSER fails when application is not built/served by Webpack #1570

Closed
fabioimpe opened this issue Jan 17, 2023 · 2 comments
Closed

IS_BROWSER fails when application is not built/served by Webpack #1570

fabioimpe opened this issue Jan 17, 2023 · 2 comments

Comments

@fabioimpe
Copy link
Contributor

Hi,
I'm facing an issue where in a browser environment MQTT library still try to use ws instead of the browser native WebSocket for the web socket connection.
After digging in the codebase I found out that the following code to understand if the code is running on node or in a browser is NOT taking care of any bundler other than Webpack (for instance I'm on Parcel 2 and is not working):

const IS_BROWSER = (typeof process !== 'undefined' && process.title === 'browser') || typeof __webpack_require__ === 'function'

In addition to this I don't understand the usage of process.title at all, I investigated a bit about this but I wasn't able to find any meaningful documentation or hint of its usage.

I think is worth having a safer way to check whether the code is running on the browser or not.

@fabioimpe
Copy link
Contributor Author

Maybe related issues:
#1233
#1412
#1523
#1441

@robertsLando
Copy link
Member

Fixed by #1571

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants