Repository navigation
Closed
Closed
Copy link
Labels
area: service-workerIssues related to the @angular/service-worker packageIssues related to the @angular/service-worker package
Milestone
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
Current behavior
I start to use service-worker SwPush feature for webpush but some mobile browser throw Cannot read property 'getSubscription' of undefined error message.
Error Message
TypeError: Cannot read property 'getSubscription' of undefined
at project(.../node_modules/@angular/service-worker/fesm5/service-worker.js.pre-build-optimizer.js:131:99)
at _next(.../node_modules/rxjs/_esm5/internal/operators/switchMap.js.pre-build-optimizer.js:34:27)
at next(.../node_modules/rxjs/_esm5/internal/Subscriber.js.pre-build-optimizer.js:54:18)
at _next(.../node_modules/rxjs/_esm5/internal/operators/map.js.pre-build-optimizer.js:41:26)
at next(.../node_modules/rxjs/_esm5/internal/Subscriber.js.pre-build-optimizer.js:54:18)
at notifyNext(.../node_modules/rxjs/_esm5/internal/operators/switchMap.js.pre-build-optimizer.js:66:26)
at _next(.../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.pre-build-optimizer.js:15:21)
at next(.../node_modules/rxjs/_esm5/internal/Subscriber.js.pre-build-optimizer.js:54:18)
at apply(.../node_modules/rxjs/_esm5/internal/util/subscribeToPromise.js.pre-build-optimizer.js:7:28)
at invoke(.../node_modules/zone.js/dist/zone.js.pre-build-optimizer.js:388:26)
at run(.../node_modules/zone.js/dist/zone.js.pre-build-optimizer.js:138:43)
at apply(.../node_modules/zone.js/dist/zone.js.pre-build-optimizer.js:872:34)
at invokeTask(.../node_modules/zone.js/dist/zone.js.pre-build-optimizer.js:421:31)
at runTask(.../node_modules/zone.js/dist/zone.js.pre-build-optimizer.js:188:47)
at drainMicroTaskQueue(.../node_modules/zone.js/dist/zone.js.pre-build-optimizer.js:595:35)
Expected behavior
No error message if PushManager is undefined.
Minimal reproduction of the problem with instructions
These two line is problem. registration.pushManager can be undefined.
https://github.com/angular/angular/blob/master/packages/service-worker/src/push.ts#L39
https://github.com/angular/angular/blob/master/packages/service-worker/src/push.ts#L42
What is the motivation / use case for changing the behavior?
I just use SwPush in service-worker
Environment
some of Android 8.0 ~ 5.0.2 Chrome / Facebook browser throw the error.
https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/pushManager#Browser_compatibility
Angular version: 6.1.4
Browser:
- [x] Chrome (Android) version 67.0.3 ~ 68.0.3
- [x] Facebook (Android) version 187
Metadata
Metadata
Assignees
Labels
area: service-workerIssues related to the @angular/service-worker packageIssues related to the @angular/service-worker package
Activity
gkalpak commentedon Sep 5, 2018
Interesting 🤔
It would be nice if we knew exactly what browser/version fails. From what I can tell, it should be supported in all major browsers (except for IE).
leo6104 commentedon Sep 5, 2018
@gkalpak In my service, 2.3k users cannot access to the service because of this issue.
Here is Sentry log (Browser statistic of this error)
53.57% | Chrome Mobile 68.0.3440 | 5 minutes ago
15.43% | Facebook 186.0.0 | 6 days ago
8.70% | Facebook 187.0.0 | a few seconds ago
6.84% | Facebook 185.0.0 | 28 minutes ago
3.99% | Chrome Mobile 66.0.3359 | 17 minutes ago
1.91% | Facebook 184.0.0 | 2 days ago
1.86% | Chrome Mobile 67.0.3396 | 5 hours ago
1.74% | Chrome Mobile 65.0.3325 | 26 minutes ago
0.92% | Chrome Mobile 20.0.0 | a day ago
0.87% | Facebook 181.0.0 | 39 minutes ago
0.46% | Chrome Mobile 44.0.2403 | 16 hours ago
0.39% | Facebook 179.0.0 | 4 days ago
0.36% | Facebook 180.0.0 | 3 hours ago
Chrome Mobile and Facebook latest version still have this issue. (But it seems not for always but specific condition make this error) I was trying to find the condition but not found yet.. 🤔
leo6104 commentedon Sep 5, 2018
Ionic PWA tools also faced this issue in their pwa project and resolved the issue.
ionic-team/ionic-pwa-toolkit#4
leo6104 commentedon Sep 5, 2018
As gkalpak said in my PR, it seems if i handle this error in
this.swPush.subscription.subscribesecond argument, it could be handle with catching error. So i close this issue.gkalpak commentedon Sep 5, 2018
Thx for the detailed info. The fact that it happens some of the time sounds like a browser bug (since there is nothing in the spec indicating that
pushManagercould be undefined).The ionic issue seems to be different, since there the registration itself is undefined (while here,
registrationis defined, butregistration.pushManageris not 🤷♂️).gkalpak commentedon Sep 5, 2018
BTW, I would be curious to know whether
window.PushManageris defined when the error happens.Serginho commentedon Mar 11, 2019
@gkalpak I can confirm this is happening, at least, in the following browsers.
Chrome WebView (70.0.3538.80) running over Android (7.0)
Chrome (72.0.3626.121) running over Android (8.1.0)
Facebook (211.0.0.43.112) running over Android (6.0.1)
Android Browser (4.0) running over Android (7.0)
Is this reported to Chromium team?
The interesting thing is we never subscribe to
SwPush.subscription, we always useSwPush.requestSubscription, but this lines is executing...angular/packages/service-worker/src/push.ts
Line 77 in 4b9eb61
gkalpak commentedon Mar 12, 2019
Not to my knowledge. If you have enough info, please report it (and post a link to the issue here).
Are you using
SwPush#unsubscribe()? If not, then that line should not be executed indeed. Happy to look into it, if you can provide a minimal reproduction.angular-automatic-lock-bot commentedon Sep 14, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.