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

Gzip seems not work in my project #945

Closed
3 tasks done
grapehunter opened this issue Nov 26, 2019 · 9 comments
Closed
3 tasks done

Gzip seems not work in my project #945

grapehunter opened this issue Nov 26, 2019 · 9 comments
Labels
bug Something does not work as it should external The issue related to an external project ✭ help wanted ✭

Comments

@grapehunter
Copy link

grapehunter commented Nov 26, 2019

What would you like to discuss?

Enviroment:
Running in render process with Electron 7 (But not use Electron.net.)

Code:
got('http://www.example.com', { decompress: true }).then(r => console.log(r.body));

Result:
image

It looks like the gzip data is not being decoded correctly

Checklist

  • I have read the documentation.
  • I have removed node_modules and reinstalled all dependencies by yarn install.
  • I have removed .yarnclean and reinstalled all dependencies by yarn install.
@szmarczak
Copy link
Collaborator

What Got version are you running?

@grapehunter
Copy link
Author

grapehunter commented Nov 26, 2019

What Got version are you running?

The latest release version with yarn add got, I think it is 9.6.0

@grapehunter
Copy link
Author

grapehunter commented Nov 26, 2019

Checked. NOT THIS REASON.

Very weird because I tested with the same code on runkit and the results were correct
Is it possible that the relevant code was cleared by yarn clean?
Here is my .yarnclean

# test directories
__tests__
test
tests
powered-test

# asset directories
docs
doc
website
images
assets

# examples
example
examples

# code coverage directories
coverage
.nyc_output

# build scripts
Makefile
Gulpfile.js
Gruntfile.js

# configs
appveyor.yml
circle.yml
codeship-services.yml
codeship-steps.yml
wercker.yml
.tern-project
.gitattributes
.editorconfig
.*ignore
.eslintrc
.jshintrc
.flowconfig
.documentup.json
.yarn-metadata.json
.travis.yml

# misc
# *.md
*.gz

@grapehunter
Copy link
Author

grapehunter commented Nov 26, 2019

I have found out the reason.
In get-response.js

const decompressResponse = require('decompress-response');

decompressResponse is not a function but a empty object.
decompress-response was disabled in package.json

"browser": {
		"decompress-response": false,
		"electron": false
	}
}

After removing "decompress-response": false,, all is working now

@szmarczak
Copy link
Collaborator

Glad you've solved the issue! PR welcome :)

@szmarczak szmarczak added bug Something does not work as it should external The issue related to an external project ✭ help wanted ✭ labels Nov 27, 2019
@szmarczak
Copy link
Collaborator

It used to work some while ago. Now electron support is broken.

@adityapk00
Copy link

Was this fixed? It seems to be broken with electron, and fails with the same error.

@szmarczak
Copy link
Collaborator

Electron support has been deprecated, as the electron.netAPI differs very much from the Node js http API.

@ci010
Copy link
Contributor

ci010 commented Mar 4, 2020

I have found out the reason.
In get-response.js

const decompressResponse = require('decompress-response');

decompressResponse is not a function but a empty object.
decompress-response was disabled in package.json

"browser": {
		"decompress-response": false,
		"electron": false
	}
}

After removing "decompress-response": false,, all is working now

Notice that the package.json referring here is from got, which means if you want to bundle got with webpack in target electron-renderer. You will need to modify the got package.json in node_modules. I think we should simply remove this field since got is a package for node environment, not the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as it should external The issue related to an external project ✭ help wanted ✭
Projects
None yet
Development

No branches or pull requests

4 participants