js-file-downloader icon indicating copy to clipboard operation
js-file-downloader copied to clipboard

Download files using HTTPS throw error on console

Open cfthody opened this issue 3 years ago • 4 comments

I am using the latest version of this package minified for an internal project of the company I work and I noticed that when using HTTPS and trying to download files in different formats it throws an error on the console. vmconnect_C0xhse8b6L But this only happens on the first try, on the next's one the download proceeds correctly and no errors are shown. Our source code that this happen is something like this vmconnect_OYNd3EWvOd I enabled the nativeFallbackOnError to true and the error was vmconnect_NpbZhz3keL So I tried debugging this function and also the endpoint and it seems that after returning the file to download it cannot be read and the error.request.response is null and the responseText is filled with [Exception: DOMException: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'arraybuffer'). vmconnect_ntIhnHOFTo

cfthody avatar Jun 14 '22 15:06 cfthody

Hi @cfthody , are you sure this issue is not related to backend problem?

AleeeKoi avatar Jun 24 '22 09:06 AleeeKoi

Yes, I'm sure. No error was found on the logs and also the BE was returning correctly the file(s) to download. But I can confirm again and attach the necessary screenshots to reinforce my statement.

cfthody avatar Jul 24 '22 07:07 cfthody

Hii @AleeeKoi, sorry for the delay in answering.

I have done some tests again, and the BE is returning the array of bytes correctly. If it helps I have put a breakpoint on the catch to check the error and is related to the minified version of the lib.

UPJ8oNXWXM

cfthody avatar Aug 16 '22 08:08 cfthody

Hi @cfthody , no worry. Could you please recreate this issue on codesandbox.io and share it with me? Thanks

AleeeKoi avatar Aug 24 '22 08:08 AleeeKoi