-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
"Module did not self-register" (Scrypt) in node.js worker thread #2723
Comments
Platform is Windows; I've tried npm rebuild, deleting node_modules and reinstalling, also have tried npm upgrade - to no avail. If anybody knows the root cause or any workaround, would be very much appreciated. Will try downgrading web3 to see if it makes any difference. |
Could you create a demo GitHub repository where I could do some more tests? |
You got an extra . in your settings somewhere. Look carefully at your error message...
Not saying that's the problem, but I'd start there. |
Thanks @nivida @sshelton76 for the input; I'll try packaging what I have into github (also will take a look at the extra .!) -- will revert ASAP. |
@nivida - https://github.com/Scoop-Tech/scpx-wallet/blob/master/README.md This repro's for me on a clean checkout. The offending line is in There's no packaging in this project, just babel-core on the entry point file ( NB: |
Worth noting: it fails in the same way if I move the require web3 to the top-level worker file ( |
UPDATE: if I defer the require('web3') and move it inside a function instead of putting it at the module/file scope, it works! Maybe some timing condition or similar, in trying to reference the web3 module immediately. Happy to have a workaround at least. |
Did you also test it with another package than Web3.js? (It doesn't look like an issue from our side) |
Yea, the other require references all work fine. As mentioned, there does seem to be a workaround (just don't require web3 at the top of the file); I'll double check that the instantiated web3 does actually work as expected, then will close. |
@dmorris99 Did you check this?:) |
I’m still trying to resolve it — the behavior is very strange; depending on where I require web3, it fails. Some places it’s fine, others it’s not. There doesn’t seem to be much pattern - in some places it fails in the main thread and works in the worker_thread, other times it’s the inverse. I did manage to check that if it gets past the require line, then any created Web3 instances seem to work just fine. From the stack trace it looks to me like some issue with scrypt dependency under certain conditions. |
@nivida -- I noticed that the module failing to initialize (https://github.com/barrysteyn/node-scrypt) is marked as deprecated on the maintainer's github page. It says https://nodejs.org/api/crypto.html#crypto_crypto_scrypt_password_salt_keylen_options_callback is preferred instead, although I guess that might not be much use in the browser. Investigation continues. The same codepath in the browser all works ok. Would like to find an environmental fix rather than hack my code to work around it. Will try upgrading Node from 10.14 to 12. |
I am facing the same issue:
Using node js version v12.2.0 |
I'll test and if required fix it asap. Thanks for all the additional information! |
Issue still exists. I didn't even realize it was related to Web3, but thanks to Google I found this here. I can confirm that
is a functioning workaround. |
Does this issue still exist also when scrypt is defined as an optional dependency? (v1.2.2 of web3.js) |
Believe this native dependency related and fixed with Now using scrypt-js which does not require a node-gyp build. Please ping if anyone is still seeing this problem. |
Description Web3 fails to initialize in node.js worker thread
Expected behavior
const web3 = require('web3') // expected: ok
Actual behavior
Steps to reproduce the behavior
run node with --experimental-workers
create a worker thread:
require web3 in the worker thread file (worker.js)
Versions
"web3": "1.0.0-beta.52",
The text was updated successfully, but these errors were encountered: