Skip to content

don't cancel the upload if you unsubscribe from AngularFireUploadTask.percentageChanges() #2685

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
leon opened this issue Nov 24, 2020 · 2 comments · Fixed by #2688
Closed

Comments

@leon
Copy link

leon commented Nov 24, 2020

Version info

Angular:
11.

Firebase:
8.16.1

AngularFire:
6.1.1

Other (e.g. Ionic/Cordova, Node, browser, operating system):
Mac OS Big Sur

How to reproduce these conditions

Failing test unit, Stackblitz demonstrating the problem
har to show, since it needs access to a writable storage bucket.
But it's a "simple" problem.

Steps to set up and reproduce

upload a file using the AngularFireStorage
whilst uploading subscribe to the percentageChanges() observable
But half way through, unsubscribe from the percentageChanges() the upload will cancel.

Expected behavior

It doesn't feel right that subscribing/unsubscribing to a progress, should impact the upload itself.

The problem lies here
https://github.com/angular/angularfire/blob/master/src/storage/observable/fromTask.ts#L16

listening to stateChanges maybe should cancel the upload if you unsubscribe.

I might be wrong about this.
But I just encountered this problem, and I thought it would be good to inform you of this.
I could not find any documentation regarding canceling of uploads, so it might be a good time to be more upfront about how it works and which use cases we should support.

Actual behavior

unsubscribe from percentageChanges() will cause the upload to cancel.

@jamesdaniels
Copy link
Member

Thanks for the report, yeah that is surprising behavior IMO. I'm going to fix in the next patch.

@jamesdaniels
Copy link
Member

Will cut with 6.1.2 this afternoon.

jamesdaniels added a commit that referenced this issue Nov 24, 2020
…and added replay (#2688)

* unsubscribing from upload progress shouldn't cancel the upload, that was undefined behavior IMO
* `shareReplay` the upload, so one could pick back up (say if they had upload progress `| async` on a view somewhere)

Closes #2685
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants