Skip to content

Cannot read property 'controller' of undefined #6657

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

Closed
nilptr opened this issue Oct 6, 2022 · 2 comments
Closed

Cannot read property 'controller' of undefined #6657

nilptr opened this issue Oct 6, 2022 · 2 comments

Comments

@nilptr
Copy link

nilptr commented Oct 6, 2022

[REQUIRED] Describe your environment

  • Operating System version: Mac OS X 10.15.7
  • Browser version: Chrome 98.0.4758
  • Firebase SDK version: 9.6.1
  • Firebase Product: performance

Actually, this error occurs on more than one specific operating system and browser version. Here are browser and OS versions we can see in Sentry.

Browsers:

  • Chrome 98.0.4758
  • Chrome 99.0.4844
  • Chrome 96.0.4664
  • Chrome 105.0.0
  • Firefox 95.0
  • Chrome 103.0.0
  • Chrome 106.0.0
  • Chrome 96.0.4606

OS:

  • Mac OS X 10.15.7
  • Windows 10
  • Mac OS X 10.14.6
  • Mac OS X 11.6
  • Mac OS X 12.2.1
  • Mac OS X 12.6
  • Mac OS X 10.15
  • Mac OS X 10.14.3
  • Mac OS X 10.14.4
  • Mac OS X 10.15.6

[REQUIRED] Describe the problem

We got Cannot read property 'controller' of undefined errors in Sentry recently.
image

The stack trace shows it comes from here.

export function getServiceWorkerStatus(): ServiceWorkerStatus {
const navigator = Api.getInstance().navigator;
if ('serviceWorker' in navigator) {
if (navigator.serviceWorker.controller) {
return ServiceWorkerStatus.CONTROLLED;
} else {
return ServiceWorkerStatus.UNCONTROLLED;
}
} else {
return ServiceWorkerStatus.UNSUPPORTED;
}
}

Although it looks already defensive enough, it doesn't catch the case that 'serviceWorker' in navigator but navigator.serviceWorker === undefined.

Steps to reproduce:

N/A

Relevant Code:

export function getServiceWorkerStatus(): ServiceWorkerStatus {
const navigator = Api.getInstance().navigator;
if ('serviceWorker' in navigator) {
if (navigator.serviceWorker.controller) {
return ServiceWorkerStatus.CONTROLLED;
} else {
return ServiceWorkerStatus.UNCONTROLLED;
}
} else {
return ServiceWorkerStatus.UNSUPPORTED;
}
}

@DellaBitta
Copy link
Contributor

Hi @nilptr,

Is this still an issue after the PR was released? Thanks!

@nilptr
Copy link
Author

nilptr commented May 31, 2023

Hi @DellaBitta, after the release, we never saw this error again.

Thanks!

@nilptr nilptr closed this as completed May 31, 2023
@firebase firebase locked and limited conversation to collaborators Jul 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants