Skip to content
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

Strange behaviour without IPFS Companion #22

Closed
fsdiogo opened this issue Aug 31, 2018 · 5 comments
Closed

Strange behaviour without IPFS Companion #22

fsdiogo opened this issue Aug 31, 2018 · 5 comments
Labels
need/triage Needs initial labeling and prioritization

Comments

@fsdiogo
Copy link
Contributor

fsdiogo commented Aug 31, 2018

When using the app with IPFS Companion everything works great 🌟

But a simple app like this should require the minimum amount of setup, that being said it should work out-of-the-box with just an IPFS daemon running.

Something strange is happening. Steps to reproduce:

  1. Disable the IPFS Companion if it's active
  2. Fire up an IPFS daemon in the terminal
  3. Start the app and upload a single file -- it should upload successfully and generate a share link
  4. Try to upload another file -- it uploads but it doesn't generate another share link as it should (and does with Companion) because the request hangs forever:
http://127.0.0.1:5001/api/v0/object/patch/add-link?arg=QmPvs3XyQqFY8sprbS6A18EqCS1b6A2FwKL8tx4DEjVRUD&arg=package.json&arg=QmdXb9kCfLv4bGHRiiFStC66JSH36Gr2y7j7hW9cnrZqUm&stream-channels=true

The problem should come from this func:

export async function makeHashFromFiles (files, ipfs) {
let node = await ipfs.object.new('unixfs-dir')
for (const file of files) {
node = await ipfs.object.patch.addLink(node.toJSON().multihash, {
name: file.name,
size: file.size,
multihash: file.hash
})
}

I can't understand why it works with Companion & it works the first time the func is called, it generates the share link. But when calling again it hangs. It also happens if you try to upload multiple files the first time, I think there is something wrong when creating the new unixfs-dir and/or adding links to it.

Ideas? @ipfs-shipyard/gui

@lidel
Copy link
Member

lidel commented Aug 31, 2018

@fsdiogo I am not sure if I reproduced the same error 🙃 , but adding multiple files worked for me until I hit this known problem with go-ipfs+js-ipfs-api.

UI froze at this state (I can't remove greyed one):

screenshot_29

You can try reproducing it by adding multiple files and then upload-multiple-files-via-browser-ipfs-api-bug-demo.zip (this .zip triggered the go-ipfs big for me, but due to the nature of the bug it may not work the same on every machine).

As you can read in https://github.com/ipfs/js-ipfs-api/issues/797#issuecomment-401469158 there is no known workaround for HTML context. The only thing we can do is to count input arguments and detect if files.add result list is too short and display error to the user. I described all the steps in ipfs/ipfs-webui#769 (comment).

You can add error handling in the app, but in the long run we probably should fix this upstream in js-ipfs-api ((https://github.com/ipfs/js-ipfs-api/issues/797)

PS. It probably worked with Companion because WebExtension has more powerful APIs than HTML JS and applies a fix for /api/v0/add.

@fsdiogo
Copy link
Contributor Author

fsdiogo commented Sep 3, 2018

@lidel adding multiple files works, the problem is that the share link doesn't get generated!

You are right, I was focusing on the share link because it was the last step that seemed to be broken, but it doesn't generate a new one because of the API problem you mentioned! Well, that sucks and takes too much fun of this app, so I would say to use Companion until the bug is solved. What do you think?

PS: The UI isn't frozen in that state, that 'x' is not clickable, although in v1.1 I'll add the ability to remove those files.

@lidel
Copy link
Member

lidel commented Sep 3, 2018

AFAIK we can't fix it from the app itself: website's JS can't set Connection nor Expect headers :(
However, I've added a new workaround for go-ipfs issue (ipfs/ipfs-companion#562) to IPFS Companion. When merged, it will finally fix issue under Chrome if user has our extension enabled.

See the PR for more details.

@fsdiogo fsdiogo mentioned this issue Sep 14, 2018
8 tasks
@lidel lidel added the need/triage Needs initial labeling and prioritization label Nov 9, 2018
@jessicaschilling
Copy link
Contributor

@lidel can we close this?

@lidel
Copy link
Member

lidel commented Feb 2, 2021

Yup, this is no longer relevant as we deprecated window.ipfs and will use js-ipfs running on the page itself.

@lidel lidel closed this as completed Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

3 participants