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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service Worker registration does not use ErrorHandler #39913

Closed
chrisguttandin opened this issue Dec 1, 2020 · 3 comments
Closed

Service Worker registration does not use ErrorHandler #39913

chrisguttandin opened this issue Dec 1, 2020 · 3 comments
Labels
area: service-worker Issues related to the @angular/service-worker package P4 A relatively minor issue that is not relevant to core functions type: bug/fix
Milestone

Comments

@chrisguttandin
Copy link
Contributor

馃悶 bug report

Affected Package

The issue is caused by package @angular/service-worker

Is this a regression?

No, I don't think so,

Description

The Service Worker registration logs an error in the console when the it fails. I think that's confusing and it would be better to use the ErrorHandler which other parts of Angular use. That way Angular users could handle the error themselves.

馃敩 Minimal Reproduction

As far as I know there is not really an easy way to reproduce this besides deploying a broken app. I hope it's okay to point to the source instead.

navigator.serviceWorker.register(script, {scope: options.scope})
.catch(err => console.error('Service worker registration failed with:', err))));

This is where the Service Worker gets registered and possible errors get logged to the console directly.

馃敟 Exception or Error





馃實 Your Environment

Angular Version:


Angular CLI: 11.0.2
Node: 12.20.0
OS: darwin x64

Angular: 11.0.2
... animations, cli, common, compiler, compiler-cli, core
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker
Ivy Workspace: 

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.2
@angular-devkit/build-angular   0.1100.2
@angular-devkit/core            11.0.2
@angular-devkit/schematics      11.0.2
@schematics/angular             11.0.2
@schematics/update              0.1100.2
rxjs                            6.6.3
typescript                      4.0.5

Anything else relevant?

I would be happy to create a PR for fixing this. Please let me know if I should do so.

@sonukapoor sonukapoor added the area: service-worker Issues related to the @angular/service-worker package label Dec 1, 2020
@ngbot ngbot bot added this to the needsTriage milestone Dec 1, 2020
@gkalpak
Copy link
Member

gkalpak commented Dec 1, 2020

Sounds reasonable 馃憤
I can't think of any reason not to pass it to the ErrorHandler and looking at the PR that introduced this (#30876), there doesn't seem it was a deliberate choice not to.

Thx for bringing it up, @chrisguttandin, and for offering to create a PR. That would be great 馃ぉ
Feel free to ping me if you need any help with the process.

@gkalpak gkalpak added P4 A relatively minor issue that is not relevant to core functions type: bug/fix labels Dec 1, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Dec 1, 2020
@chrisguttandin
Copy link
Contributor Author

Thanks for taking a look, @gkalpak. I created #39990 to address the issue.

@mhevery mhevery closed this as completed in 74e42cf Dec 8, 2020
mhevery pushed a commit that referenced this issue Dec 8, 2020
Errors thrown by calling serviceWorker.register() are now passed to the global ErrorHandler.

Fixes #39913

PR Close #39990
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: service-worker Issues related to the @angular/service-worker package P4 A relatively minor issue that is not relevant to core functions type: bug/fix
Projects
None yet
Development

No branches or pull requests

3 participants