-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
@ethersproject/random not working properly in service worker #2405
Comments
This is quite possible. I'll schedule this fix for the next release. :) |
This should be fixed in 5.5.3. Can you try it out and let me know if you still have any problems? Thanks! :) |
Happy to hear that! I'll get the time to try the new version out about next Tuesday. |
@ricmoo |
Awesome! Glad to hear it. :) Thanks! |
Describe the bug
I'm using ethers.js on a wallet (chrome-extension) project.
Everything worked well in when testing in web pages. But when I move the code to
background.js
(run as a service worker), it starts to complain about "no secure random source avaialble" (<-- a typo here!).Actually I solved this issue in my project by adding following code into the beginning of the service worker code:
So I believe we can be avoid of this issue by adding another condition here:
ethers.js/packages/random/src.ts/browser-random.ts
Lines 12 to 23 in 73a46ef
Hope I'm understanding the error correctly.
Reproduction steps
Run any code that uses
randomBytes
in@ethersproject/random
under service worker environment.Environment:
Win10 Desktop
Chrome v96
Chrome Extension Manifest V3 background service worker
Search Terms
getRandomValues
UNSUPPORTED_OPERATION
service worker
crypto
no secure random source avaialble
The text was updated successfully, but these errors were encountered: