filestack / filestack-js

Official Javascript SDK for the Filestack API and content ingestion system.
https://www.filestack.com
MIT License
206 stars 76 forks source link

Issue when closing picker while upload still ongoing #432

Open lk77 opened 3 years ago

lk77 commented 3 years ago

Expected Behavior

When picker is closed, upload is properly cancelled if an upload was ongoing when the picker was closed

Current Behavior

The picker hang and produce an error on the console

Error: FS-Cannot upload file part
    at new e (filestack.umd.js:16510)
    at filestack.umd.js:22605
(anonymous) @ picker.js:1
p.emit @ filestack.umd.js:2786
(anonymous) @ filestack.umd.js:24754
p.emit @ filestack.umd.js:2786
(anonymous) @ filestack.umd.js:23124
p.emit @ filestack.umd.js:2786
(anonymous) @ filestack.umd.js:22109
(anonymous) @ filestack.umd.js:361
(anonymous) @ filestack.umd.js:291
s @ filestack.umd.js:254
Promise.then (async)
c @ filestack.umd.js:261
a @ filestack.umd.js:246
Promise.then (async)
c @ filestack.umd.js:261
a @ filestack.umd.js:246
Promise.then (async)
c @ filestack.umd.js:261
(anonymous) @ filestack.umd.js:264
a @ filestack.umd.js:243
(anonymous) @ filestack.umd.js:22066
(anonymous) @ filestack.umd.js:22065
(anonymous) @ filestack.umd.js:22064
(anonymous) @ filestack.umd.js:361
(anonymous) @ filestack.umd.js:291
(anonymous) @ filestack.umd.js:264
a @ filestack.umd.js:243
e.execute @ filestack.umd.js:22058
(anonymous) @ filestack.umd.js:23230
(anonymous) @ filestack.umd.js:361
(anonymous) @ filestack.umd.js:291
a @ filestack.umd.js:246
Promise.then (async)
c @ filestack.umd.js:261
(anonymous) @ filestack.umd.js:264
a @ filestack.umd.js:243
e.upload @ filestack.umd.js:23214
e.upload @ filestack.umd.js:24756
(anonymous) @ picker.js:1
Promise.then (async)
uploadOne @ picker.js:1
(anonymous) @ picker.js:1
Uo.dispatch @ picker.js:1
Uo.dispatch @ picker.js:1
uploadMoreMaybe @ picker.js:1
(anonymous) @ picker.js:1
Uo.dispatch @ picker.js:1
Uo.dispatch @ picker.js:1
startUploading @ picker.js:1
(anonymous) @ picker.js:1
Uo.dispatch @ picker.js:1
Uo.dispatch @ picker.js:1
Yo.forEach.i.<computed> @ picker.js:1
startUploadMaybe @ picker.js:1
je @ picker.js:1
i @ picker.js:1
Fn.o._wrapper @ picker.js:1
picker.js:1 Uncaught (in promise) TypeError: Cannot read property 'error' of undefined
    at e.<anonymous> (picker.js:1)
    at e.p.emit (filestack.umd.js:2786)
    at e.<anonymous> (filestack.umd.js:24754)
    at e.p.emit (filestack.umd.js:2786)
    at e.<anonymous> (filestack.umd.js:23124)
    at e.p.emit (filestack.umd.js:2786)
    at e.<anonymous> (filestack.umd.js:22109)
    at filestack.umd.js:361
    at Object.throw (filestack.umd.js:291)
    at s (filestack.umd.js:254)

Possible Solution

Catch the Error: FS-Cannot upload file part error and avoid the type error that follows.

Steps to Reproduce (for bugs)

  1. Set network speed to slow 3g to have enough time
  2. Start a file upload
  3. Close the picker
  4. See the error in the console

Additional Screenshots

Here a video capture of the issue, using the picker on the documentation page

https://user-images.githubusercontent.com/9606882/114420987-1d6cfd80-9bb5-11eb-9d2c-5764b3cc1c7c.mp4

Context

Users sometimes close by mistake the picker before the upload is complete, and we would like to warn the user about that, so he can try again, currently the picker fail and we cant display a warning to the user.

Your Environment