register-service-worker: Error: Undefined is not a function when registering the service worker

I am getting a weird error on a production application when the service worker is registered. I cannot reproduce it on my own devices and it appear to only happen less than one percent of the time.

Our analytics tells us that some devices gets an “undefined is not a function” at https://github.com/yyx990803/register-service-worker/blob/master/src/index.js#L44 on the then call. This seems to indicate that the register() call returned undefined which is not valid according to the spec.

The devices that trigger those errors are running Android 7, 8 or 8.1 and using Chrome 70, 71 or Samsung Internet 7.4 or 8 or 8.1 so they should have support for service workers. We are also getting calls from those browsers/os that do work fine.

I don’t think there is much that can be done on your side beside checking the result of the register call and emiting an error if it’s not a promise. Have you even seen this problem before? I can’t seem to find anyone complaining about this.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 11
  • Comments: 15

Most upvoted comments

We are getting the same errors reported through bugsnag: undefined is not a function

node_modules/register-service-worker/index.js:47 - registerValidSW

If any information or a fix is possible, would be great.

Yeah, but maybe in Blink instead? As the above-mentioned user-agent strings are all from Chrome.

@kawazoe You can find me on discord as sodatea#9125. My email’s haoqunjiang@gmail.com.

Update since July, the exception is caught every now and then and happens across all combinations of users/devices/OS’s/browsers. (currently 184 events over 41 users) It’s strange that the ‘ready’ function is defined but ‘register’ is not, possibly a race condition during the serviceWorker init?