# ServiceWorker denkt, ich sei offline, obwohl ich es nicht bin

**URL:** https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886
**Category:** Bug
**Created:** [12. Januar 2018 um 20:57 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886 "2018-01-12T20:57:16Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [12. Januar 2018 um 20:57 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/1 "2018-01-12T20:57:16Z")

</div>

Today I visited a PM, deleted it, silenced the user, then after navigating back (back button) through it I got an offline error. It persisted when I tried to continue going back to meta mainpage.

> It looks like you are offline! Please check your network connection and try again.

I can duplicate the problem by [visiting the topic](https://meta.discourse.org/t/advertising-inquiry/77877) normally then hitting Ctrl-R to reload:

[https://global.discourse-cdn.com/meta/original/3X/3/c/3c19a6e3eb126c25a9100ead566b2793e7dba220.mp4](https://global.discourse-cdn.com/meta/original/3X/3/c/3c19a6e3eb126c25a9100ead566b2793e7dba220.mp4)

The error page that I get is coming from Service Worker:

![image](https://global.discourse-cdn.com/meta/original/3X/8/a/8abd5df8cdc3b0e5af58c9cf0d1a5bcbc7d931ee.png)

I’m on Chrome Version 63.0.3239.132 (Official Build) (64-bit)

* * *

This _kind of smells_ like it’s related to [https://meta.discourse.org/t/sorry-we-couldn-t-load-that-topic-possibly-due-to-a-connection-problem/40078/11?u=supermathie](https://meta.discourse.org/t/sorry-we-couldn-t-load-that-topic-possibly-due-to-a-connection-problem/40078/11).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [13. Januar 2018 um 03:04 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/2 "2018-01-13T03:04:17Z")

</div>

Can you repro this @jomaxro?

---

<div class="post-metadata">

### Author: ![ewanly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ewanly/32/62854_2.png) [@ewanly](https://meta.discourse.org/u/ewanly)
#### Post date: [19. Januar 2018 um 20:42 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/4 "2018-01-19T20:42:26Z")

</div>

I’m not able to access the site at all -with the same error.

# " Cannot load app

It looks like you are offline! Please check your network connection and try again. "

* * *

I’d tried in Chrome and Firefox last versions. Rebuild is not helping too.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [19. Januar 2018 um 22:02 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/5 "2018-01-19T22:02:48Z")

</div>

Here’s the worker code being triggered:

```plaintext
if ("navigate" === t.request.mode ||
  "GET" === t.request.method && t.request.headers.get("accept").includes("text/html")) {

t.respondWith(fetch(t.request).catch(function(t) {
        return caches.match(OFFLINE_URL)
    }))
}

```

So the fetch is failing somehow, which doesn’t include non-200 status codes.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [20. Januar 2018 um 01:10 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/6 "2018-01-20T01:10:22Z")

</div>

This is usally due to rogue plugins. Try in Firefox [safe mode](https://meta.discourse.org/t/53504?silent=true) / Chrome incognito and report back?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [20. Januar 2018 um 04:29 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/7 "2018-01-20T04:29:25Z")

</div>

One thing I really want is a site setting to disable service workers, firstly this feature means that now everyone has to keep downloading this service worker file (we only have it cached for one day and the name can not change)

Secondly Safari seems to have a slightly more dodgy implementation that may be causing issues, it would be nice to be able to just turn this off on a site to see if it fixes stuff.

---

<div class="post-metadata">

### Author: ![ewanly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ewanly/32/62854_2.png) [@ewanly](https://meta.discourse.org/u/ewanly)
#### Post date: [20. Januar 2018 um 05:04 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/8 "2018-01-20T05:04:47Z")

</div>

Firefox [safe mode](https://meta.discourse.org/t/53504?silent=true) / Chrome incognito helped me to see that LetsEncrypt need renewal. Thank you, everything ok now after renewal.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [26. Januar 2018 um 18:31 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/9 "2018-01-26T18:31:35Z")

</div>

No - I’ve not been able to repro this over the past 2 weeks of using Discourse. That said, it might be resolved by our recent service worker work…

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [26. Januar 2018 um 22:25 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/10 "2018-01-26T22:25:09Z")

</div>

Not much done, everything I did got reverted.

The underlying issue is what @riking mentioned, there are other exception cases that we are not handling. Probably worth testing DNS failure on local and seeing what comes back from the worker.

Also maybe we should only bother passing through the promise if navigator.onLine is false?  
[Navigator: onLine property - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine). I wonder how implemented this is these days @awole20?

---

<div class="post-metadata">

### Author: ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)
#### Post date: [27. Januar 2018 um 01:12 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/11 "2018-01-27T01:12:29Z")

</div>

The complication here is that navigator is not available to service workers, so it might be simpler to detect and handle offline cases from the exception in the catch.

A big issue here is that the service worker catch clause squelches way too much, and perhaps it would be advantageous to pipe a message in the catch clause to the main js app to display or log for debugging.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [27. Januar 2018 um 01:14 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/12 "2018-01-27T01:14:36Z")

</div>

Possible, or perhaps ship online state to the worker from the app

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [27. Januar 2018 um 01:23 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/13 "2018-01-27T01:23:44Z")

</div>

> [@sam](#):
>
> Probably worth testing DNS failure on local and seeing what comes back from the worker.

I noticed the other day browsing to sjctoo (which no longer exists) gave the “you are offline” error from ServiceWorker.

---

<div class="post-metadata">

### Author: ![lw1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lw1/32/82012_2.png) [@lw1](https://meta.discourse.org/u/lw1)
#### Post date: [28. Februar 2018 um 17:56 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/14 "2018-02-28T17:56:25Z")

</div>

Hi everyone,

There is a user on our forum ([forum.matomo.org](http://forum.matomo.org)) who is having a really similar issue.

After clicking on an external link and pressing `back`, he isn’t able to access the forum any more, but only gets an `Cannot load app - It looks like you are offline! Please check your network connection and try again` error.  
Removing the service worker only fixes the issue temporarily.

Does anyone have an idea on how to fix it and avoid getting the error again

You can find more information here:  
[https://github.com/matomo-org/matomo/issues/12588](https://github.com/matomo-org/matomo/issues/12588)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [28. Februar 2018 um 21:08 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/15 "2018-02-28T21:08:47Z")

</div>

Make sure the user making the report is not using a beta browser, that is essential.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [28. Februar 2018 um 21:45 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/16 "2018-02-28T21:45:33Z")

</div>

Yeah we really need the exact version of the browser, the OS and confirmation this happens with all plugins disabled.

---

<div class="post-metadata">

### Author: ![mcnesium](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcnesium/32/133983_2.png) [@mcnesium](https://meta.discourse.org/u/mcnesium)
#### Post date: [1. März 2018 um 09:42 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/17 "2018-03-01T09:42:04Z")

</div>

I have been experiencing this on lots of Discourse forums lately, running current stable Firefox on Linux and Mac

not using Adblock Plus, but [Privacy Badger](https://www.eff.org/privacybadger) and [Decentraleyes](https://decentraleyes.org)

---

<div class="post-metadata">

### Author: ![lw1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lw1/32/82012_2.png) [@lw1](https://meta.discourse.org/u/lw1)
#### Post date: [1. März 2018 um 09:57 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/18 "2018-03-01T09:57:28Z")

</div>

Answer from the user

> [@fdellwing](#):
>
> Using FF58 on Ubuntu 14, it’s the current stable version. Will try it tomorrow in [safe mode](https://meta.discourse.org/t/53504?silent=true) (no addons and default config).

> [@fdellwing](#):
>
> Ok, I was able to pin it down to Adblock Plus.
> 
> The interesting part here is, it does not matter if you have it enabled on [matomo.org](http://matomo.org), which I haven’t. It only matters if the addon at all is enabled in `about:addons` . I’m quite sure this is a bug, but I’m not able to tell if the bug is in the addon or in the forum software, but I have not got this problem anywhere else.

(from [Matomo forums - Cannot load app · Issue #12588 · matomo-org/matomo · GitHub](https://github.com/matomo-org/matomo/issues/12588#issuecomment-369400096))

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [1. März 2018 um 14:21 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/19 "2018-03-01T14:21:02Z")

</div>

> [@lw1](#):
>
> Ok, I was able to pin it down to Adblock Plus.

Confirmed! Disabling Adblock Plus also makes _my_ [symptoms](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886) go away!

There’s definitely an unexpected interaction here with ABP and ServiceWorker.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [1. März 2018 um 15:00 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/20 "2018-03-01T15:00:32Z")

</div>

I recommend the uBlock Origin instead of ABP: [https://github.com/gorhill/uBlock#performance](https://github.com/gorhill/uBlock#performance)

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [1. März 2018 um 15:35 UTC](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886/21 "2018-03-01T15:35:58Z")

</div>

> [@Falco](#):
>
> I recommend the uBlock Origin instead of ABP

That _also_ makes the problem go away 😃

[Nächste Seite](https://meta.discourse.org/t/serviceworker-thinks-im-offline-when-im-not/77886.md?page=2)
