Cancelling requests with service worker

This issue has been created since 2022-11-17.

Which @angular/* package(s) are the source of the bug?

service-worker

Is this a regression?

No

Description

When using a service worker and cancelling http requests (via unsubscribe for example), the underlying call made by service worker is not cancelled.

This could cause several issues like reaching maximum number of connections opened to a backend or useless backend load.

To reproduce the issue you can use the project I shared in github which is triggering calls to a slow backend and cancelling the calls except the last one (with and without service worker). You can see that, when using service worker, that last call have to wait for all the "cancelled" calls to be done before being fired.

I attach two screenshots of the demo code you can find in the repository.

Screenshot 2022-11-17 at 15 01 43

Screenshot 2022-11-17 at 15 02 16

Please provide a link to a minimal reproduction of the bug

https://github.com/oliveti/sw-cancellation-demo-2

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 14.2.9
Node: 16.14.0
Package Manager: npm 9.1.2 
OS: darwin arm64

Angular: 14.2.11
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.9
@angular-devkit/build-angular   14.2.9
@angular-devkit/core            14.2.9
@angular-devkit/schematics      14.2.9
@angular/cli                    14.2.9
@angular/pwa                    0.5.3
@schematics/angular             14.2.9
rxjs                            7.5.7
typescript                      4.7.4

Anything else?

No response

More Details About Repo
Owner Name angular
Repo Name angular
Full Name angular/angular
Language TypeScript
Created Date 2014-09-18
Updated Date 2022-12-01
Star Count 85220
Watcher Count 3042
Fork Count 22607
Issue Count 1316

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Exception during startup in beta9 2 2022-09-06 2022-09-24
Modelform field override issue 4 2018-01-13 2022-09-10
Clicking on infraction detail not showing infraction 3 2021-10-31 2022-11-04
dark-mode-minor-mode not working 2 2022-10-18 2022-10-22
Question on location of last_played_list 1 2022-09-22 2022-10-14
Add autoconfiguration of playlist_directory 0 2022-09-20 2022-10-14
Request to flag invalid contract name 0 2022-01-30 2022-10-02
No easy way to adjust H2 connection settings 0 2021-05-19 2022-09-26
Message send policy with not responsive client 5 2021-05-21 2022-11-29
New flag behavior for the CLI 5 2022-01-20 2022-11-28
Issues while processing json containing braces 6 2021-11-09 2022-11-18
inconsistent behaviour with case-sensitive role names 1 2022-04-26 2022-11-20
Wait Result Option does not work 1 2021-12-09 2022-11-26
Typescript support 2 2018-09-26 2022-01-08
Issue with the implementing Drop-In delegate 14 2022-01-10 2022-10-31
[NEED ASSIST] Start Paypal registration flow in app locally 2 2022-01-25 2022-11-06
Python ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:661) 12 2018-08-14 2022-11-09
units and constants and NEP 42 9 2022-07-15 2022-09-07
Datetime with optional time is not displaying the values correctly 2 2022-02-22 2022-11-24
ranges.h breaks with const vector of custom type 3 2022-10-12 2022-11-23
reprex() not reproducing perfectly even after setting seed 4 2021-06-25 2022-11-11
Error: `highlight` call unsuccessful 0 2021-06-14 2022-11-11
Hello, Does the plugin work stable with UE5? 1 2022-08-10 2022-08-12
the string provided in credentials is neither valid json nor a valid file path 1 2021-12-29 2022-11-22
When switching to a video room with unread messages, automatically open the chat panel 0 2022-06-10 2022-10-05
Publish > cannot expand/collapse block 2 2022-03-08 2022-11-16
[Bug]: gd and K don't work on a NestJS project 8 2021-09-24 2022-11-04
build(deps): bump @yearn-finance/web-lib from 0.13.0 to 0.13.13 2 2021-08-13 2022-11-13
改版后18章PBR 18.2的一些纠错 以及提供缺失的shader代码 2 2021-12-15 2022-11-17
Stars component needs more informative tooltips 0 2022-09-27 2022-09-21
Who is managing who? 1 2021-09-06 2022-10-14
Block List actions overlay is invisible if custom view uses z-index 1 2022-03-11 2022-08-30
blob output binding - query string parameters 2 2022-01-23 2022-09-03
[1.4.12] "No route to host" When trying to connect on Roku TV or Roku Express 2 2022-07-08 2022-11-15
S927 False positive on discard 5 2021-10-26 2022-11-10
Select API not replicating AWS behavior when columns are missing 0 2021-09-10 2022-10-27
permissions goes wrong after running php bin/magento setup:di:compile command 4 2021-10-11 2022-10-08
no matches for kind "Deployment" in version "extensions/v1beta1" 1 2020-07-30 2022-11-22
Procedura attivazione 0 2022-10-18 2022-11-15
Define multiple project subdirectories 2 2021-07-21 2022-11-19
Custom encoder listed in the encoders/x86 directory is not listed with msfvenom --list encoders command 5 2022-03-08 2022-11-25
adding alexnet prototype model 0 2021-10-20 2022-05-31
Set default color mode extra parameters 0 2022-03-16 2022-11-23
command to align text from right to left (rtl) 4 2022-08-13 2022-08-22
[BUG] docker events `kill` reported as error but are normal event of a graceful shutdown. 0 2022-11-24 2022-11-24
types missing? 8 2020-04-27 2022-01-04
Cluster agent is not connected 3 2022-07-02 2022-09-17
Boxplot only shows a `<NULL>` in x-axis 1 2021-10-04 2022-11-12
V5 Utilities: Add Border Style 1 2021-12-03 2022-11-07
doesnt work with "author" described as an object 1 2022-01-26 2022-11-18