FineUploader / fine-uploader

Multiple file upload plugin with image previews, drag and drop, progress bars. S3 and Azure support, image scaling, form support, chunking, resume, pause, and tons of other features.
https://fineuploader.com
MIT License
8.19k stars 1.87k forks source link

JS error when concurrent chunking is denied by server side validation (traditional server) #1542

Open slava-uxd opened 8 years ago

slava-uxd commented 8 years ago

Type of issue: Bug? Uploader type: traditional Fine Uploader version: 5.5.1 Browsers where the bug is reproducible: All Operating systems where the bug is reproducible: Windows 7

Steps to reproduce the issue

  1. Upload a file using concurrent chunking, deny it server-side with a valid JSON response.
  2. Browser console throws error: [Fine Uploader 5.5.1] Error when attempting to parse xhr response text (JSON.parse: unexpected end of data at line 1 column 1 of the JSON data)
  3. After that, xhr.response and xhr.responseText are empty inside onError() callback, which makes other data in the response not readable. Although errorReason does contain text from a server's 'error' response.

Only happens when concurrent chunking is enabled. Non-concurrent chunking = ok. Single-file uploads = ok.

rnicholus commented 8 years ago

Thanks for the report. This is likely caused by Fine Uploader's failure to check the status of the response before attempting to parse the response. In this case, it is likely hitting a request for one chunk in a batch of concurrent file chunks that has been cancelled internally as a result of another chunk failure. The status is most likely 0, which indicates cancellation and therefore this request will not have a response. The issue appears to be benign. I'll look into including a patch in a future release.