Fix putFileResumable failing on a successful upload on Apple targets - #850
Open
anggrayudi wants to merge 1 commit into
Open
Fix putFileResumable failing on a successful upload on Apple targets#850anggrayudi wants to merge 1 commit into
anggrayudi wants to merge 1 commit into
Conversation
The Apple putFileResumable closed its ProgressFlow with a FirebaseStorageException on FIRStorageTaskStatusSuccess, so a completed upload surfaced to the collector as a failure. On success the snapshot has no error, so the exception carried the message "null" and the only way to use the API was to swallow it -- by which point the file had in fact uploaded. putDataResumable, 35 lines above and otherwise identical, already closes normally on success, as does the Android implementation, whose OnCompleteListener calls close(it.exception) with a null exception on success. Match them. Fixes GitLiveApp#722
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #722.
Problem
On Apple targets,
putFileResumableclosed itsProgressFlowwith an exception when the upload succeeded:A success snapshot has no error, so
it.error()isnulland the collector received aFirebaseStorageExceptionwhose message was the string"null". That's exactly what @zacsst reported — an error on completion, and "if i swallow it, the file was successfully uploaded", because by then the upload really had finished.Why this is unambiguous
putDataResumablesits 35 lines above in the same file and is otherwise identical toputFileResumable— same fourobserveStatusblocks, sameawaitClose, same returnedProgressFlow. Its success handler is:ios.observeStatus(FIRStorageTaskStatusSuccess) { close() }So the correct code is already in the file; only
putFileResumablegot it wrong.Android agrees on the intended semantics — its completion listener is
close(it.exception), andit.exceptionisnullon success, which is a normal close:Fix
One line: close the flow normally on success, matching
putDataResumableand Android.On testing
Two things worth being explicit about rather than glossing over.
I could not run the build or tests locally — Gradle dependency resolution stalls in my environment and I never got a green or red run, same as I noted on #847 and #848. Please treat CI as the real check.
No existing test could have caught this.
commonTesthastestPutDataResumable, which doesref.putDataResumable(data, metadata).collect {}— acollectthat would throw if the flow closed exceptionally, so it is the right shape of test. But it exercisesputDataResumable, the method that was already correct. There is noputFileResumableequivalent.I didn't add one because it needs more than a copy-paste:
Fileis platform-specific (File(NSURL)on Apple,File(Uri)on Android), andcommonTestcurrently has no way to produce one — there's noFile(usage in any test source. Doing it properly means anexpect fun createTestFile(): Fileintest-utilswith an actual per target that writes a temp file, which is a bigger change than this fix and one I'd rather not bundle in silently. Happy to do it as a follow-up if you'd like the coverage.