-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Uncaught Error : Callback was already called(exchange-files-in-browser) #2153
Comments
@hapsody thanks for the bug report. I believe this is due to a restriction with WebCrypto where it will not load in a page unless that page is loaded over https, or the page is served from localhost: libp2p/js-libp2p-crypto#105 I guess the solution is that we should update the example to include a warning about this restriction. Would you be interested in opening a PR to do so? |
@dirkmc Thank you for your reply. You mean that it's a known problem about libp2p/js-libp2p-crypto#105 not solved yet? so we can only change the guide yet. Do I understand correctly? I don't know exactly about a sort of PR thing since I'm a newbie for opensource process. |
@hapsody that's correct, it's a known issue. If you would like to contribute a PR we would appreciate it. To create a PR against this project, you can
|
I think "PR" means "Pull Request" |
Yes PR means Pull Request, you can find more information here: |
This example doesn't work except the case in localhost ( related to ipfs#2153) This is known because of a restriction with WebCrypto (libp2p/js-libp2p-crypto#105) I add a explanation of a example's restriction to run
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 <[email protected]>
This example doesn't work except the case in localhost ( related to #2153) This is known because of a restriction with WebCrypto (libp2p/js-libp2p-crypto#105) I add a explanation of a example's restriction to run
Changes `webcrypto.js` to check for native web crypto availability and falls back to using `window.__crypto` if not available. If the user wants to bring their own Web Crypto API compatible implementation then they simply need to assign it to `window.__crypto` before they start using IPFS. Checks are done in the functions that require web crypto to give the user the flexibility to assign to `window.__crypto` before OR after they import `libp2p-crypto`. It also means that users have the ability to use other exported functions that do not require web crypto without having to worry about sorting their own implementation. We use `window.__crypto` because `window.crypto` is a readonly property in secure context and always readonly in workers. If `window.crypto` and `window.__cypto` are unavailable then an appropriate error message is reported to the user with a `ERR_MISSING_WEB_CRYPTO` code. I've also added documentation to the README. This is a backwards compatible change. closes #149 resolves #105 resolves ipfs/js-ipfs#2017 resolves ipfs/js-ipfs#2153 License: MIT Signed-off-by: Alan Shaw <[email protected]>
This PR simply detects missing web crypto and throws an error with an appropriate message. This is a stepping stone that will help users understand the problem until we have time to do a refactor of this module and of all the modules that use it to enable optionally passing your own crypto implementation. refs #149 refs #150 refs #105 refs ipfs/js-ipfs#2153 refs ipfs/js-ipfs#2017 License: MIT Signed-off-by: Alan Shaw <[email protected]>
This PR simply detects missing web crypto and throws an error with an appropriate message. This is a stepping stone that will help users understand the problem until we have time to do a refactor of this module and of all the modules that use it to enable optionally passing your own crypto implementation. refs #149 refs #150 refs #105 refs ipfs/js-ipfs#2153 refs ipfs/js-ipfs#2017 License: MIT Signed-off-by: Alan Shaw <[email protected]>
This PR simply detects missing web crypto and throws an error with an appropriate message. This is a stepping stone that will help users understand the problem until we have time to do a refactor of this module and of all the modules that use it to enable optionally passing your own crypto implementation. refs libp2p#149 refs libp2p#150 refs libp2p#105 refs ipfs/js-ipfs#2153 refs ipfs/js-ipfs#2017 License: MIT Signed-off-by: Alan Shaw <[email protected]>
This example doesn't work except the case in localhost ( related to ipfs/js-ipfs#2153) This is known because of a restriction with WebCrypto (libp2p/js-libp2p-crypto#105) I add a explanation of a example's restriction to run
Version:
js-ipfs version: 0.36.2-
Repo version: 7
System version: x64/darwin
Node.js version: v11.10.1
Platform:
Darwin neojuneui-MacBook-Pro-146.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
Chrome 74.0.3729.169 (official build) 64-bit
Subsystem:
Maybe, it's about libp2p, if I'm correct.
Type: Question
Severity: High
Description:
Exchange-files-in-browser example doensn't work except case in localhost
Steps to reproduce the error:
I've checked a guide right below. It seems to be a perfect guide to me on the same machine.
https://github.com/ipfs/js-ipfs/tree/master/examples/exchange-files-in-browser
But If I tried to download a file on another machine. I got an error message from browser trying to connect
(A computer in the same local network. for example, A server node sharing a file is 192.168.0.22. request node trying to download the file is 192.168.0.33)
Error Message
The text was updated successfully, but these errors were encountered: