elFinder icon indicating copy to clipboard operation
elFinder copied to clipboard

"TypeError: Cannot read property 'debug' of undefined"

Open liquidaty opened this issue 3 years ago • 2 comments

Hi,

I'm getting a "TypeError: Cannot read property 'debug' of undefined" error if:

  1. I click download on a file
  2. the server responds to the download request with an error
  3. I click the "x" in "Downloading files" to cancel the request

This seems to demonstrate two bugs:

  1. No error is displayed when the download link fails. It should display an error and no longer show the "Downloading" progress box
  2. Clicking the "x" button to abort is not properly handling the valid (204) response

Could you please take a look and lmk if you need any further information to identify and/or resolve these issues?

Thank you much

liquidaty avatar Mar 05 '21 23:03 liquidaty

@liquidaty This is a nasty problem. When downloading with a modern browser, clicking Download will bring it under the control of the browser. I don't know how to catch that progress in JavaScript.

One thing I would like to ask is "TypeError: Cannot read property 'debug' of undefined". Do you know where the error occurred?

nao-pon avatar Jun 10 '21 07:06 nao-pon

When downloading with a modern browser, clicking Download will bring it under the control of the browser

It doesn't have to be that way. IMHO a much better way to handle this would be to not hand control over to the browser. Instead, create a new XMLHttpRequest() object to fetch the URL, with an onload handler that will fetch the xhr.response into a blob and programmatically invoke the downloaded through a regular download-local-content routine (e.g. that would typically make a call to URL.createObjectURL()).

This should be no problem for files of up to several gigabytes in size, and gives you full control over the entire process as the data comes over the wire. This would probably prove useful for many other reasons as well.

The only drawback I can think of is that if you're downloading a large file and you want the user to see progress over time, then when you give the browser control, the browser will do that for you, whereas with the above approach, you need to add some of your own code to do that. But that's a fairly easy thing to code and there are a lot of other advantages to this approach that are not available otherwise.

liquidaty avatar Jun 17 '21 14:06 liquidaty

This issue is stale because it has been open for 50 days with no activity.

github-actions[bot] avatar Aug 11 '23 02:08 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Aug 25 '23 02:08 github-actions[bot]