-
Notifications
You must be signed in to change notification settings - Fork 59
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
bug: aegir/fixtures loadFixtures
incorrectly alters bytes in the browser
#1462
Comments
I think the problem here is that your test loads a gzipped tarball, and something is decompressing it before returning it as the The bit-twiddling comes from here btw - unfortunately the bytes have already been decompressed by this point so the bug is not there. |
I think the bug is in A workaround is to just rename the |
When loading a file that ends in `.gz`, `sirv` will set the `Content-Encoding` header to `gzip` which means browsers will unzip the content before handing it back to `fetch` or `XMLHttpRequest`. This PR adds a workaround to the asset server that sets the header to a garbage value if a file ending in `.gz` has been requested. It's necessary to use a garbage value because `sirv` will only set the header if it's not been set already, so we can't simply delete it. Refs: lukeed/sirv#158 Refs: ipfs/aegir#1462
When loading a file that ends in `.gz`, `sirv` will set the `Content-Encoding` header to `gzip` which means browsers will unzip the content before handing it back to `fetch` or `XMLHttpRequest`. This PR adds a workaround to the asset server that sets the header to a garbage value if a file ending in `.gz` has been requested. It's necessary to use a garbage value because `sirv` will only set the header if it's not been set already, so we can't simply delete it. Refs: lukeed/sirv#158 Refs: ipfs/aegir#1462
But the gz is the expected type, which returns correctly with a simple http server and piping fs.createReadStream |
Thanks for the quick responses and bugfix in playright-test |
Renaming the file doesn't make it a different type, it just stops It's just a workaround to unblock you while the issue is fixed upstream. |
Test loading gzipped fixtures, particularly in browsers. Prevents regressions of #1462
Test loading gzipped fixtures, particularly in browsers. Prevents regressions of #1462
Closing as a workaround has been released in hugomrdias/playwright-test#644 so this is usable now and the proper fix is discussed in lukeed/sirv#158 |
Describe the bug
When using the
loadFixtures
function fromaegir/fixtures
in the browser, the bytes returned are incorrectly altered, causing test failures in https://github.com/SgtPooki/file-type.Repro code in branch at https://github.com/SgtPooki/file-type/pull/new/repro/aegir-load-fixtures-browser-bug
To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/SgtPooki/file-type
cd file-type
git checkout repro/aegir-load-fixtures-browser-bug
npm i && npm run test
Expected behavior
The browser tests pass, the same as they do in the node tests.
Screenshots
Desktop (please complete the following information):
aegir@42.2.3
Additional context
The specific failing test can be ran by running
npm run test -- -g 'fixture.tar.gz 65'
. You'll see that the test passes in node, but fails in the browser test.The text was updated successfully, but these errors were encountered: