-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Uncaught TypeError: Cannot read property 'generateKey' of undefined #964
Comments
Found the error: it seems like we need to deploy over HTTPS for IPFS to work. @diasdavid can you confirm this is the case? |
@lightninglu10 HTTP or HTTPS should not be related. Note that the code is running in your browser and dialing to an IPFS node running in Node.js, correct? What is the version of Node.js running in your EC2 instance? |
The code is running in my browser but dialing to an IPFS node running in Go. I think the HTTPS/HTTP is relevant as I only ran into this error:
from the browser's native webcrypto |
@lightninglu10 is your go endpoint behind a SSL termination proxy? //cc @lgierth who can share some tricks here :) |
@lightninglu10 is your go endpoint behind a SSL termination proxy? //cc @lgierth who can share some tricks here :) Do note that if this was really an HTTPS issue, the browser node should fail dialing on the transport and would never get to SECIO (which is where that generateKey happens). I'm intrigued by how you have things set up as I'm not figuring out what is the codepath you are hitting in your particular situation. |
Not sure if they are related but I reported a bug in the shared-editor repo which may be the same one ipfs-shipyard/shared-editing-demo#4 . Note - it occurs in recompiled code, not the one in that repo. That one also only occurs when working remote, but not locally. |
TIL that WebCrypto is restringed to HTTPS pages It seems that WebCrypto does require a secure context to run and that is not granted in non HTTPS loaded pages. It has an exception for localhost though. Apologies @lightninglu10, you are totally right. It is a HTTPS/HTTP issue. |
Opened a issue to discuss and reach a conclusion for the preferred solution libp2p/js-libp2p-crypto#105 |
Let's track it there |
This PR adds `crypto-browserify` to the dependencies and replaces `crypto` with `crypto-browserify` when bundled in the browser. In files that require webcrypto we check to see if it's available. If it is not we require the Node.js implementation (which has `crypto` replaced with `crypto-browserify`) and if it is available then we use the webcrypto version (so we get fast crypto). Shipping `crypto-browserify` adds to the bundle size: Current gzipped size: 142,824 bytes New gzipped size: 214,499 bytes Difference: **+71,675 bytes** It's not an insignificant addition so we need to decide whether this is worth it. If not accepted, we need to add checks when libp2p-crypto methods are called and callback with an appropriate error message. JS IPFS will continue to have issues opened with confusion around this otherwise! See ipfs/js-ipfs#963 ipfs/js-ipfs#964 ipfs/js-ipfs#2153 resolves #105 License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
Type: Bug
Severity: High
Description: When trying to connect to IPFS on an amazon ec2 instance, I get the error:
It seems like it's coming from the webcrypto package. But it's weird because it works locally for me, it's only when I deploy to ec2 that all of a sudden things go haywire.
I also get the error:
Uncaught Error: Callback was already called.
Steps to reproduce the error:
Will put up a website in a second.
The text was updated successfully, but these errors were encountered: