ipfs / js-ipfsd-ctl

Control an IPFS daemon (go-ipfs or js-ipfs) using JavaScript!
https://ipfs.github.io/js-ipfsd-ctl
Other
154 stars 62 forks source link

HTTPError: Bad Request when spawning go daemon inside electron process #502

Open mistakia opened 4 years ago

mistakia commented 4 years ago

Getting an error when trying to run this in an electron renderer process and running the electron example produces the same errors.

HTTPError: Bad Request
    at HTTP.fetch (/Users/xxx/Projects/js-ipfsd-ctl/examples/electron-asar/node_modules/ipfsd-ctl/node_modules/ipfs-utils/src/http.js:147:13)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
    at async Client.init (/Users/xxx/Projects/js-ipfsd-ctl/examples/electron-asar/node_modules/ipfsd-ctl/src/ipfsd-client.js:88:17)
    at async Factory.spawn (/Users/xxx/Projects/js-ipfsd-ctl/examples/electron-asar/node_modules/ipfsd-ctl/src/factory.js:141:7)
    at async EventEmitter.<anonymous> (/Users/xxx/Projects/js-ipfsd-ctl/examples/electron-asar/app.js:27:18) {
  name: 'HTTPError',
  response: Response {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: false, error: null },
    [Symbol(Response internals)]: {
      url: 'http://localhost:43134/init?id=oY3V-7miM627hvksEMHlh',
      status: 400,
      statusText: 'Bad Request',
      headers: [Headers],
      counter: 0
    }
  }
}

versions

"ipfsd-ctl@file:../..":
  version "4.0.1"

"go-ipfs-dep@github:ipfs/npm-go-ipfs-dep#add-path-function-to-detect-binary":
  version "0.4.23"

ipfs-http-client@^38.2.0:
  version "38.2.1"
achingbrain commented 4 years ago

Can you try pinning the go-ipfs-dep version to 0.4.23-3 please? It's later than 0.4.23 but npm doesn't always resolve it as such.

Really it should have been released as 0.5.0 (or preferably 1.0.0) but for some reason people want to keep the version of that module tied to the go-ipfs version it downloads by default.

mistakia commented 4 years ago

hmm - I have since resolved the issue in an electron project by looking at the ipfs-desktop implementation, which has go-ipfs-dep pinned at 0.4.23-3. The only material changes I made in my project are using the same versions being used in ipfs-desktop (go-ipfs-dep@0.4.23-3 ipfs-http-client@44.0.0 ipfsd-ctl@4.0.1) so I'm assuming that was part of the resolution.

However, I tried running the electron example with go-ipfs-dep@0.4.23-3 and got the same error 🤷‍♂️

Edit: I tried the latest version (4.1.0) of the electron example and am still getting the same error. Strange I'm not seeing this issue in any other projects lol.

tymmesyde commented 4 years ago

I think it's because of the remote option, you have to set it to false. Apparently, it should automatically be set to false if it recognizes that it is in a node environment but does not seem to work.