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

newbie - errors #5

Closed
acerov opened this issue Oct 13, 2015 · 10 comments
Closed

newbie - errors #5

acerov opened this issue Oct 13, 2015 · 10 comments

Comments

@acerov
Copy link

acerov commented Oct 13, 2015

Hi,

I am totally new to serviceworker. Just installed broccoli-serviceworker following the instructions on ember-cli 1.13.9 but when rest api server is not accessible I am receiving following errors:

Got error for dynamic url, try to pull from cache: TypeError: Failed to fetch at TypeError (native)

The FetchEvent for "http://localhost:4000/v1/clients" resulted in a network error response: an object that was not a Response was passed to respondWith().

@jkleinsc
Copy link
Owner

@acerov what browser were you using? did you put your rest server api in the dynamicCache section in your environment.js file?

@acerov
Copy link
Author

acerov commented Nov 23, 2015

@jkleinsc chrome 46.0.2490.86 m, but I tried with firefox also (service worker not supported), in environment.js I have:
ENV.serviceWorker = { enabled: true, serviceWorkerFile: "service-worker.js", excludePaths: ['tests/', 'online.html',], includePaths: ['/'], fallback: [ '/online.html offline.html' ], dynamicCache: [ '/v1' ] };
I am using ember 1.13.9 and ember-data 1.13.14

@jkleinsc
Copy link
Owner

You could try adding the debug option in environment.js to add console logging to see where the caching is failing:

javascript
ENV.serviceWorker = {
enabled: true,
serviceWorkerFile: "service-worker.js",
excludePaths: ['tests/', 'online.html',],
includePaths: ['/'],
fallback: [ '/online.html offline.html' ],
dynamicCache: [ '/v1' ],
debug: true
};


As an aside, I am planning on using [Google's Service Worker Toolbox](https://github.com/GoogleChrome/sw-toolbox) in the next version of broccoli-serviceworker, which should hopefully better handle or avoid errors like this.

@acerov
Copy link
Author

acerov commented Nov 23, 2015

@jkleinsc thank you for your effort but with debug: true nothing changed, just the same error from first post, no new error details

@jkleinsc
Copy link
Owner

Are you seeing any output in the developer console? debug:true adds console statements to the service worker so you can see what it is attempting to do. If you are not seeing any additional output try doing a refresh/hard refresh in your browser.

@acerov
Copy link
Author

acerov commented Nov 23, 2015

I had to go to chrome://inspect/#service-workers and click inspect and there are the same errors:
Handling fetch event for http://localhost:4000/v1/clients
Pulling dynamic url: http://localhost:4000/v1/clients from network and adding to cache.
Found dynamic cache response: http://localhost:4000/v1/clients
GET http://localhost:4000/v1/clients net::ERR_CONNECTION_REFUSED
Got error for dynamic url, try to pull from cache: TypeError: Failed to fetch at TypeError (native)
The FetchEvent for "http://localhost:4000/v1/clients" resulted in a network error response: an object that was not a Response was passed to respondWith().

@jkleinsc
Copy link
Owner

@acerov I am refactoring the code to use https://github.com/GoogleChrome/sw-toolbox which should resolve this issue. I will let you know when that update is available.

@acerov
Copy link
Author

acerov commented Nov 25, 2015

@jkleinsc great, I will be happy to test it :)

jkleinsc added a commit that referenced this issue Dec 3, 2015
Changes to use sw-toolbox.
Resolves #12.
Should also address #5
jkleinsc added a commit that referenced this issue Dec 3, 2015
Changes to use sw-toolbox.
Resolves #12.
Should also address #5
@jkleinsc
Copy link
Owner

jkleinsc commented Dec 3, 2015

@acerov I just published a new version 0.0.5 which should resolve your issue. Let me know if you still run into problems. One thing of note, the configuration has changed slightly - includePaths is now called precacheURLs.

@acerov
Copy link
Author

acerov commented Dec 6, 2015

@jkleinsc what can I say, it just works :) thank you!

@acerov acerov closed this as completed Dec 6, 2015
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