Browse Source

core: tighten duck type check for file objects (#3006)

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Renée Kooi 3 years ago
parent
commit
e6071855b9
1 changed files with 3 additions and 2 deletions
  1. 3 2
      packages/@uppy/core/src/index.js

+ 3 - 2
packages/@uppy/core/src/index.js

@@ -1095,7 +1095,8 @@ class Uppy {
 
       this.setState({ error: errorMsg })
 
-      if (file != null) {
+      // When a file is also given, we store the error on the file object.
+      if (file != null && typeof file.id === 'string') {
         this.setFileState(file.id, {
           error: errorMsg,
           response,
@@ -1591,7 +1592,7 @@ class Uppy {
     // Not returning the `catch`ed promise, because we still want to return a rejected
     // promise from this method if the upload failed.
     lastStep.catch((err) => {
-      this.emit('error', err, uploadID)
+      this.emit('error', err)
       this.removeUpload(uploadID)
     })