瀏覽代碼

Don’t emit a complete event if an upload has been canceled

Fixes #1186
Artur Paikin 6 年之前
父節點
當前提交
142d4d3f87
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      packages/@uppy/core/src/index.js

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

@@ -1197,6 +1197,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)