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

JSZip Returns an empty blob when ZipObject.async used #2115

Closed
franciscolosardo opened this issue Aug 21, 2019 · 10 comments · May be fixed by dyna-dot/testcafe#1
Closed

JSZip Returns an empty blob when ZipObject.async used #2115

franciscolosardo opened this issue Aug 21, 2019 · 10 comments · May be fixed by dyna-dot/testcafe#1
Assignees
Labels
STATE: Auto-locked Issues that were automatically locked by the Lock bot SYSTEM: new client-side API SYSTEM: URL processing
Milestone

Comments

@franciscolosardo
Copy link

What is your Scenario?

Our app uses jszip to uncompress files from a zip. We get this file through a request and later try to unzip it using jszip.
At a certain point this command is run :

def.async('blob').then(content => new ContentData(path, content)

where def is a ZipObject.

What is the Current behavior?

When using our app without testcafe everything works properly, it returns a blob with correct filesize.
When using our app through testcafe the blob returned is size 20 and it turns out to be an empty string. It returns 20 whether the file is empty or it contains content. Each file provided from the zip file returns 20 and finally an empty file.

This makes decompressing these files impossible through testcafe's hammerhead.

What is the Expected behavior?

Decompressing with JSZip on testcafe should first get the correct size when using async on a jszip ZipObject of type binary

What is your public web site URL?

Your website URL (or attach your complete example):

Your complete app code (or attach your test files):
 **def.async('blob').then(content => new ContentData(path, content)**
Screenshots:

Steps to Reproduce:

  1. Get a zip file over a request
  2. Use jszip to filter through the files inside
  3. Finally use async function on zipobjects to get the size and type of each.

Your Environment details:

  • node.js version: 10.15.1
  • browser name and version: Chrome 76
  • platform and version: Mac Os
  • other:
@franciscolosardo
Copy link
Author

franciscolosardo commented Aug 21, 2019

More info on method used at :
https://stuk.github.io/jszip/documentation/api_zipobject/async.html

@AndreyBelym
Copy link
Contributor

Thank you for your report. Could you please share a page and a test that can be used to reproduce the problem? Otherwise, I will need to create my own example. It will take some time and it's not guaranteed that the problem will be reproduced with it.

@franciscolosardo
Copy link
Author

Hey! I'll check with my superiors if the page can be shared and gladly will do so.
I'll keep you informed, thanks for the feedback!

@franciscolosardo
Copy link
Author

franciscolosardo commented Aug 23, 2019

Hey, great news!
Not only was i able to provide you a fiddle but also im providing the zip which causes the problem.

https://jsfiddle.net/L6adh8g1/98/

You can use the button to make the request to the zip and try to decompress it with jszip.
Check the console on the same chrome tab to see the result of the jsZipObject.async function on each one of the files inside.

You'll notice it returns 20 filesize for each file using testcafe and without using testcafe it returns different file size for each.

Hope this helps bring out a solution!

@AndreyBelym
Copy link
Contributor

AndreyBelym commented Aug 26, 2019

Thank you for sharing your example. Unfortunately, I get the following error when I try to run it without TestCafe:

Error text

M20:14 GET https://exchange2-asset-manager-kdev.s3.amazonaws.com/190700e2-6ae3-4e65-8516-1d722d1c3d47/cf003e9f19f78c4943554ef662ec2003f7f7cce9bc4525946afa24e175d159a8.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIYB37QTPDEASHYSQ%2F20190823%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190823T180820Z&X-Amz-Expires=86400&X-Amz-Signature=f0a9e23f2ce2ed45d46a8acd8ae282f49007078e57fb2b7e1d8a81b0f533b149&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dcatalystexampleapi_1050318620059-1.0.0-raml.zip 403 (Forbidden)
action @ VM20:14
callCallback @ react-dom.development.js:341
invokeGuardedCallbackDev @ react-dom.development.js:391
invokeGuardedCallback @ react-dom.development.js:448
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:462
executeDispatch @ react-dom.development.js:594
executeDispatchesInOrder @ react-dom.development.js:616
executeDispatchesAndRelease @ react-dom.development.js:719
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:727
forEachAccumulated @ react-dom.development.js:701
runEventsInBatch @ react-dom.development.js:744
runExtractedPluginEventsInBatch @ react-dom.development.js:875
handleTopLevel @ react-dom.development.js:6026
batchedEventUpdates @ react-dom.development.js:2342
dispatchEventForPluginEventSystem @ react-dom.development.js:6121
dispatchEvent @ react-dom.development.js:6150
unstable_runWithPriority @ react.development.js:2820
runWithPriority$2 @ react-dom.development.js:11443
discreteUpdates$1 @ react-dom.development.js:21810
discreteUpdates @ react-dom.development.js:2357
dispatchDiscreteEvent @ react-dom.development.js:6104

jszip.min.js:13 Uncaught (in promise) Error: Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html
    at h.readEndOfCentral (VM17 jszip.min.js:13)
    at h.load (VM17 jszip.min.js:13)
    at VM17 jszip.min.js:13
readEndOfCentral @ jszip.min.js:13
load @ jszip.min.js:13
(anonymous) @ jszip.min.js:13
Promise.then (async)
action @ VM20:14
callCallback @ react-dom.development.js:341
invokeGuardedCallbackDev @ react-dom.development.js:391
invokeGuardedCallback @ react-dom.development.js:448
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:462
executeDispatch @ react-dom.development.js:594
executeDispatchesInOrder @ react-dom.development.js:616
executeDispatchesAndRelease @ react-dom.development.js:719
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:727
forEachAccumulated @ react-dom.development.js:701
runEventsInBatch @ react-dom.development.js:744
runExtractedPluginEventsInBatch @ react-dom.development.js:875
handleTopLevel @ react-dom.development.js:6026
batchedEventUpdates @ react-dom.development.js:2342
dispatchEventForPluginEventSystem @ react-dom.development.js:6121
dispatchEvent @ react-dom.development.js:6150
unstable_runWithPriority @ react.development.js:2820
runWithPriority$2 @ react-dom.development.js:11443
discreteUpdates$1 @ react-dom.development.js:21810
discreteUpdates @ react-dom.development.js:2357
dispatchDiscreteEvent @ react-dom.development.js:6104

image

image

I also tried to view it without the editor (https://jsfiddle.net/L6adh8g1/98/show) but still get the same error. Could you please check if it works correctly on your side?

@franciscolosardo
Copy link
Author

Oh im sorry this might be the file we were accessing was deleted, let me try and find the same file through other url and publish again the jsfiddle
Thanks!

@franciscolosardo
Copy link
Author

Sorry about that, this is the new fiddle

https://jsfiddle.net/y14ac0vs/

@Farfurix Farfurix self-assigned this Aug 27, 2019
@AndreyBelym AndreyBelym added this to the Sprint #40 milestone Aug 28, 2019
@franciscolosardo
Copy link
Author

I had to finally edit the js fiddle to fetch a url that doesn't expire.

This is the final fiddle, im sorry for the inconvenience. It's pretty hard to actually find a way to serve a file with a direct url to work with fetch.

https://jsfiddle.net/jx6f3dve/11/

@Farfurix
Copy link
Contributor

@franciscolosardo

Hello,

Thank you for the sample "JSFiddle" project.
I've reproduced the issue. Our team will research it and check for a suitable solution.

@lock
Copy link

lock bot commented Sep 20, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked Issues that were automatically locked by the Lock bot label Sep 20, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
STATE: Auto-locked Issues that were automatically locked by the Lock bot SYSTEM: new client-side API SYSTEM: URL processing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants