Skip to content

Firebase Storage - StorageTask cannot be canceled while the network connection is unavailable #3700

Open
@nikolajakshic

Description

@nikolajakshic

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Bumblebee 2021.1.1 Patch 3
  • Firebase Component: Storage
  • Component version: firebase-storage:20.0.1

[REQUIRED] Step 3: Describe the problem

StorageTask cannot be canceled while the network connection is unavailable.

Relevant Code:

suspend fun reproduceBug() {
    // STEP 1 - turn off network connection (wifi/mobile)
    val task = FirebaseStorage.getInstance()
        .getReference("my-firebase-storage.json")
        .getFile(File("my-file-pathname"))
    task.addOnCanceledListener {
        // even though task.cancel() returns true,
        // listener will not be called until network connection gets established
    }
    task.addOnCompleteListener {
        // even though task.cancel() returns true,
        // listener will not be called until network connection gets established
    }
    delay(5000)
    val isCanceled = task.cancel() // returns true, but not canceled
}

StorageTask goes into 'canceling' state:


ExponentialBackoffSender is stuck in the while loop, wasting resources, until it hits max-wait-time or network connection is established, because 'cancel' is not yet called.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions