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

Instructions to demonstrate this? #9

Open
mitra42 opened this issue Mar 22, 2018 · 5 comments
Open

Instructions to demonstrate this? #9

mitra42 opened this issue Mar 22, 2018 · 5 comments

Comments

@mitra42
Copy link

mitra42 commented Mar 22, 2018

Are there a set of instructions to get this working ?

What I figured so far ...

  • Clone the repo from here
  • cd to ipfs-service-worker
  • npm install
  • cd examples
  • npm run build
  • cp -r public+sw/* dist/public+sw

Then copy all of dist/public+sw to a http server
Access for example /public+sw/index.html

It reports ...

-> Registered the service worker successfuly
bundle.js:1:807398
install step
service-worker-bundle.js:1:1582000
activate step

so it looks like the SW is activated.

But ...clicking on window.ipfs.id gets:

 TypeError: asm.js type error: expecting argument type declaration for 'e' of the form 'arg = arg|0' or 'arg = +arg' or 'arg = fround(arg)'
TypeError: e(...) is undefined

and putting a IPFS hash in the input box results in e.g.

Handling fetch event for http://localhost:8080/ipfs/zb2rhfUz7JSdBBb39AHrhtiMLFa5XV2h8Ni1mGz8D67NNKsZg

So it looks like service worker is getting the request, but it never returns.

I'm not sure if I'm doing something wrong (e.g. I didn't change config from the repo default) or if its still early days for this?

@mitra42
Copy link
Author

mitra42 commented Mar 22, 2018

Some more info ... in case its useful
First time I run this in the browser I see the "activate step" in the console, but not the events after IPFS successfully loads.
Close the browser, restart, and this "activate step" doesn't occur. I don't know if part of FF or Chrome remains in memory, but if not then it suggests that on subsequent runs its not trying to connect to IPFS.
Attempts to retrieve a IPFS hash after a browser restart report service-worker-bundle.js:1 Uncaught (in promise) TypeError: Cannot read property 'files' of undefined
at service-worker-bundle.js:1
at self.addEventListener.e (service-worker-bundle.js:1)
which suggests that "node" is undefined, i.e. confirming that its lost whatever connection to IPFS its had.

Hope that's helpful ...

@mitra42
Copy link
Author

mitra42 commented Mar 22, 2018

I created a pull request to fix the problems above and upgrade to newer webpack and ipfs

@vasco-santos
Copy link
Member

vasco-santos commented Apr 20, 2018

Hello @mitra42, I tried the current version in master as you described, as well as your PR implementation.

The master version worked perfectly for me using the steps as you described:

  • Clone the repo from here
  • cd to ipfs-service-worker
  • npm install
  • cd examples/use-from-another-page
  • npm install
  • npm run build
  • run using http-server

However, with your version, I couldn't manage to use get window.ipfs.id nor fetch working.

Note: The use-from-another-page example should have its usage explained, as you did in the PR.

@mitra42
Copy link
Author

mitra42 commented Apr 20, 2018

Hi Vasco - I'm not sure what the problem was with the PR, I did quite a bit of work on it post this PR to get a service worker version of our archive.app page going. In the end I skipped using the ipfs proxy because it was too hard to follow what the code did, and we needed to make some changes, and instead rewrote message passing to the Service Worker.

I'm just in the process of posting it to its own repo which I'll share in a few days, it probably won't get much more attention because we have to use webtorrent for the videos (because of some other IPFS issues) and webtorrent won't currently work in a SW because of the lack of WebRTC in ServiceWorkers.

One thing that was definitely clear was that we had to start IPFS at the activate stage, not at the install stage. The install is not getting run on second accesses etc, so as I reported above its trying to access a undefined "node".

@vasco-santos
Copy link
Member

vasco-santos commented Apr 20, 2018

@mitra42 you are right regarding the second access. Master version has problems on a page refresh 🤔

I will appreciate that you share that when available, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants