-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Conflict with MongoDB and 'window.crypto.getRandomValues' #4241
Comments
Hi @Gredys thanks for bringing this to our attention! Do you have a specific git repo we can look at or more reproduction steps so we can dig in further? Just to verify, what environment are you running this in? Are you attempting to run your code in the browser or are you in a node environment? |
Hello @fainashalts . |
Sorry. Was busy few weeks. Tomorrow gonna create this example. |
Hey @Gredys just let us know when you have a simple example that we can test against and we'll try and figure out a solution! |
@eggplantzzz I am really sorry for wasting your time. Here is an example project - truffle-issue-4241 I used Ganache and local instance of MongoDB with evertying set on default. Example output of my migration log
Command used to get this issue - |
No problem at all, thanks for reporting it. I'll try and look into this for you! So to reproduce the error just run the migrations? Can you give me specific steps to take? |
Once migration script will output information about current migration (Contract) - script will try to save that infomation in MongoDB and you will get call stack exception. P.S. Sorry for my language knowing :D |
Thanks @Gredys! And you are fine :) |
I think webpack recommends a different fix for the missing crypto lib problem. Check out KorbinianKuhn's answer here. They recommend to use crypto-browserify to shim that library. You can see the errors that webpack gives that prescribe this on this stack overflow issue. Perhaps that will resolve this issue if we can implement that in place of the shim currently in Truffle. https://github.com/trufflesuite/truffle/blob/develop/packages/core/cli.js#L6-L10 |
Issue
When trying to call insert method to MongoDB in migration deploy callback it raises stack overflow exception on calling
getRandomValues
in crypto bundle.Steps to Reproduce
Expected Behavior
Data will be inserted correctly without exceptions rised by truffle bundles
Actual Results
Exception when trying to save anything to DB.
Truffle bundles
getRandomValues
method that utilizes crypto bundle. (file853.bundled.js
)But in same time method
getRandomValues
===crypto.getRandomValues
and this leading to infinite loop.Environment
truffle version
): Truffle v5.4.3 (core: 5.4.3)node --version
): Node v14.17.1npm --version
): 7.20.0Additional information
Adding code (between double start symbols **) to supplied bundle (
853.bundled.js
) fixes issue.The text was updated successfully, but these errors were encountered: