Browse Source

Merge pull request #1271 from transloadit/fix/result-removed-upload

Don’t emit a complete event if an upload has been canceled
Artur Paikin 6 years ago
parent
commit
32b4491007
1 changed files with 4 additions and 0 deletions
  1. 4 0
      packages/@uppy/core/src/index.js

+ 4 - 0
packages/@uppy/core/src/index.js

@@ -1201,6 +1201,10 @@ class Uppy {
       // always refers to the latest state. In the handler right above it refers
       // always refers to the latest state. In the handler right above it refers
       // to an outdated object without the `.result` property.
       // to an outdated object without the `.result` property.
       const { currentUploads } = this.getState()
       const { currentUploads } = this.getState()
+      if (!currentUploads[uploadID]) {
+        this.log(`Not setting result for an upload that has been canceled: ${uploadID}`)
+        return
+      }
       const currentUpload = currentUploads[uploadID]
       const currentUpload = currentUploads[uploadID]
       const result = currentUpload.result
       const result = currentUpload.result
       this.emit('complete', result)
       this.emit('complete', result)