-
Notifications
You must be signed in to change notification settings - Fork 253
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(NODE-4211): Do not require crypto in browser builds #500
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small changes - thanks for the PR!
I've also verified the output and bson.esm.js is the only artifact that correctly contains the |
@durran out of curiosity, why was |
When can we expect a release with this fix? |
Thanks for releasing the new version. We are using this library in our code with webpack and we are getting this error/warning-
Any idea? |
Got the solution. As the error already says, webpack 5 no longer adds the polyfills by default as described here. So the solution was to add the followings in
and install The other option is to disable the polyfills completely-
|
@sagrawal31 I think there might be something wrong with your dependencies. This PR fixes the issue described by you and the fix was released with bson version 4.6.5 |
Thanks for spotting this @rvanmil. I also had the same concern but I freshly installed the npm packages and looked for |
Your webpack configuration only has |
Thanks, @rvanmil. Making that change no longer shows that warning/error. So far, I was under the impression that Do you also mind clarifying two things for me, please-
|
Hi @sagrawal31, the cryptographically secure pseudorandom number generator is attempted to be found in Node.js from I would consult this first section of the specification of ObjectIds to see if there is a concern for your use case. To quickly summarize, ObjectIds use a combination of second granularity timestamp, unique process id (randomly generated) and a in-memory counter (that starts at a random offset). Hopefully that helps! |
Hi, @nbbeeken. Thanks for the detailed response. I have been processing your information and did some tests internally. However, unfortunately, we can still see a lot of duplicates being generated on the browsers when our code is being executed on a website crawled by Google crawlers. We consider this is happening because Google must be using some sort of device blueprints to crawl the applications. Although we are now stopping our code execution on crawlers and we'll keep an eye on and update here on any further findings. |
Description
What is changing?
This adds the
@rollup/plugin-replace
plugin, which is used to set aprocess.browser
variable, to allow Rollup to create different builds for Node.js and browsers.The check for
process.browser
was added to thedetectRandomBytes
function, which should now only requirecrypto
in the js bundle, whenprocess.browser
was set to false while Rollup was running.Is there new documentation needed for these changes?
I don't think so.
What is the motivation for this change?
The issue fixed by this change is described over here: https://jira.mongodb.org/browse/NODE-4211