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

"Service worker response error" after upgrade to CRA3 #7537

Closed
danielkcz opened this issue Aug 14, 2019 · 7 comments
Closed

"Service worker response error" after upgrade to CRA3 #7537

danielkcz opened this issue Aug 14, 2019 · 7 comments

Comments

@danielkcz
Copy link

danielkcz commented Aug 14, 2019

We have the CRA3 app (react-scripts 3.1.1, not ejected) that is just fine across multiple platforms and devices. But one specific case is Android native app which runs the app in Google WebView (wrong business decision, don't ask).

Sadly, the problem is rather random and happens on app reload where service worker responds with code 500 and fails to provide one or more of the chunks. There are no further details for the error. Also, no app updates happen during that time. I can even disconnect from the network and it still happens.

image

With CRA2 it works just fine. Even if I simply downgrade to latest react-scripts@2, make a build, the problem never occurs.

Looking through changelog only possible suspect seems upgrade of workbox to V4.

ping @r0ughnex as the author of #6725 and possibly @rovansteen who was trying help me in #6243 and @jeffposnick as a Google guy :)


In case it's relevant, we have pretty much the same service-worker.js that is shipped with CRA except some extra hooks to detect updates and such. Then we have this ugly script that's shipped inside the build and injected into a workbox setup with customize-cra. It's used to postMessage from the app when a user clicks on "update now" button.

self.addEventListener('message', event => {
  if (event.data == 'apply-update') {
    self.skipWaiting().then(() => {
      self.clients.claim().then(() => {
        self.clients.matchAll().then(clients => {
          clients.forEach(client => client.postMessage('update-applied'))
        })
      })
    })
  }
})
@stale
Copy link

stale bot commented Sep 14, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Sep 14, 2019
@danielkcz
Copy link
Author

danielkcz commented Sep 15, 2019

Yea, I did not expect much from this. The current workaround is to disable service worker based on UA. It's far from ideal, but I wasn't able to find a culprit.

@stale stale bot removed the stale label Sep 15, 2019
@stale
Copy link

stale bot commented Oct 15, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Oct 15, 2019
@pierreneter
Copy link
Contributor

can you make a small repo contains this issue for example?

@stale stale bot removed the stale label Oct 15, 2019
@danielkcz
Copy link
Author

danielkcz commented Oct 15, 2019

@pierreneter Thanks for the response.

I wasn't even able to reproduce it reliably myself. It's one of those random errors, but frequent enough to be considered the issue. Besides, I am not really sure how I would reproduce here something that happens in WebView in Android devices.

The current workaround of disabling service worker in WebView seems to be sufficient although not ideal for sure.

I was mostly hoping here that someone might have experienced something similar and point me in some direction, but so far it doesn't seem to be the case.

@stale
Copy link

stale bot commented Nov 14, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Nov 14, 2019
@stale
Copy link

stale bot commented Nov 19, 2019

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Nov 19, 2019
@lock lock bot locked and limited conversation to collaborators Nov 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants