Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export for a particular combination fails with "Failed-Network error" #19

Open
sreeraj-rajendran opened this issue Mar 14, 2019 · 8 comments
Labels

Comments

@sreeraj-rajendran
Copy link

We have an issue while trying to export the data for a specific Tester from a Suite. The export always fails with the message - "Failed-Network error" - this happens in Chrome, but the download also fails in IE and Edge,

The export works fine for other combinations.

Also tried from different network and machines to eliminate network / AV issues.
The browser developer traces and fiddler shows no errors.

I am not a developer, please excuse any mistakes in my queries:
I was able to verify that the code works fine until the below function, and fails on a.click().

function SaveFileDataUri(data, fileName, type) {
    var a = document.body.appendChild(document.createElement("a"));
    a["download"] = fileName;
    a.href = "data:text/" + type + ";base64," + data;
    a.innerHTML = "download";
    a.target = "_blank";
    a.click();
    document.body.removeChild(a);
}

The "data" shows as 4.2 MB.

I am not sure if it is happening because of the direct data transfer.
window.navigator.msSaveOrOpenBlob stays null in the below function, and it chooses to go via SaveFileDataUri(btoa(data), fileName, type);

function SaveFile(data, fileName, type) {
if (window.navigator.msSaveOrOpenBlob != null) {
SaveFileMsBlob(str2bytes(data), fileName, type);
}
else {
SaveFileDataUri(btoa(data), fileName, type);
}
}

Will there be any issues with the SaveFileDataUri method with data sizes around 4.2 MB?

Thanks for the help.

@mattias-skold
Copy link
Contributor

Do you get any file downloaded at all ? Can you poosible share it (by emailing it to [email protected]) ?

Does the tester name contains any "special" characters ?

@sreeraj-rajendran
Copy link
Author

Thanks @mattias-skold for checking on this.
No, the file doesn't get downloaded at all. It immediately fails with a "Network error" message.

There are no special characters in the Tester Name.
I am able to export another suite successfully, by filtering with the same Tester.

@mattias-skold
Copy link
Contributor

Could you:

  • press F12 in the browser to activate DevTools
  • rerun the failing export
  • switch back to the devtools window, copy the content of the console tab and share with me (email to [email protected])

@sreeraj-rajendran
Copy link
Author

Thanks @mattias-skold. I would probably need to get approvals before sharing that data, I will update you on that. Is there anything that I could do / look with the data from the console to find any possible issues?

Thanks again for the help!

@sreeraj-rajendran
Copy link
Author

@mattias-skold , I was checking the solution for this post: https://stackoverflow.com/questions/39374157/angular-save-file-as-csv-result-in-failed-network-error-only-on-chrome

I then tried forcing the download to use a blob, and then the download works fine, and I am able to open the file as well, fine.

I have indicated the code changes with comments below:

function SaveFile(data, fileName, type) {
    if (window.navigator.msSaveOrOpenBlob != null) {
        SaveFileMsBlob(str2bytes(data), fileName, type);
    }
    else {
    // old - SaveFileDataUri(btoa(data), fileName, type);   
	SaveFileDataUri(str2bytes(data), fileName, type);
    }
}
exports.SaveFile = SaveFile;
function SaveFileDataUri(data, fileName, type) {
    var blob = new Blob([data], {type: 'application/vnd.ms-excel'}); //added
    var a = document.body.appendChild(document.createElement("a"));
    a["download"] = fileName;
   //old - a.href = "data:text/" + type + ";base64," + data;
    a.href = window.URL.createObjectURL(blob); //added
    a.innerHTML = "download";
    a.target = "_blank";
    a.click();
    document.body.removeChild(a);
}

Can you please let me know if this could have been an issue with handling the save operation and whether the modifications look good?

Thanks!

@sreeraj-rajendran
Copy link
Author

@mattias-skold can you please let me know if you had a chance to check the details shared in the previous post -- thank you very much for the help!

@mattias-skold
Copy link
Contributor

@sreeraj-rajendran I'm not sure what you want me to check ? Overall I think it looks good, but I havent got into details on browser compat issues.

If it works for you - use it. If you submit a PR Ill investigate the browser compat and test it on different browsers and version before accepting the PR.

@sreeraj-rajendran
Copy link
Author

Thanks @mattias-skold .
I will try and submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants