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

Error with got decompressResponse is not a function #95

Closed
lukechu10 opened this issue Mar 4, 2020 · 9 comments
Closed

Error with got decompressResponse is not a function #95

lukechu10 opened this issue Mar 4, 2020 · 9 comments
Labels

Comments

@lukechu10
Copy link
Contributor

lukechu10 commented Mar 4, 2020

When I use any method that has some kind of http request, I get the following error:

Type Error: decompressResponse is not a function

Here is my code:

import { Installer } from "@xmcl/installer";
import path from "path";

(async () => {
	const temp = await Installer.getVersionList();
	const app = remote.app;
	await Installer.install("client", temp.versions[0], path.join(app.getPath("userData"), "./game/"));
})();

Edit
Auth module still seems to work because if I recall correctly, it uses window.fetch instead of got.

@ci010 ci010 added the bug label Mar 4, 2020
@ci010
Copy link
Collaborator

ci010 commented Mar 4, 2020

That's pretty strange...

The only related issue in got is this and it seems you don't have that config in package.json.

Just to confirm, is this code fragment run over the renderer process? I have no clue on top of my mind now... Maybe I can clone your project and check it locally. Does the master branch is up-to-date?

@ci010
Copy link
Collaborator

ci010 commented Mar 4, 2020

This is a problem of got and I've opened a PR to fix it. Currently, the workaround is manually removing the browser field in package.json of got in node_modules. This is described in the issue.

@lukechu10
Copy link
Contributor Author

That's pretty strange...

The only related issue in got is this and it seems you don't have that config in package.json.

Just to confirm, is this code fragment run over the renderer process? I have no clue on top of my mind now... Maybe I can clone your project and check it locally. Does the master branch is up-to-date?

It should be on the refactor/instance-store branch and yes, the code fragment is run in the renderer process. I am also using webpack if that makes any difference. If you don't want to clone the repo locally, you can just use this (in fact, this should also have some changes I did for testing):
Open in Gitpod

@ci010
Copy link
Collaborator

ci010 commented Mar 4, 2020

Actually, I have propose a PR to fix. It just a guide to migrate to new API. You don't need to merge it.

For the decompressResponse is not a Function, currently, you have to modify the package.json of got js... Or wait it publish new version.

@lukechu10
Copy link
Contributor Author

What does the browser field in package.json do? This seems to fix the issue on Windows but I still have the issue on Linux.

@ci010
Copy link
Collaborator

ci010 commented Mar 6, 2020

What does the browser field in package.json do? This seems to fix the issue on Windows but I still have the issue on Linux.

In node_modules/got/package.json:

{
  "browser": { "module-name": true/false }
}

If the module-name is false, webpack will ignore it in bundle. It should work for all the platform, as it's the behavior of webpack...

@lukechu10
Copy link
Contributor Author

What does the browser field in package.json do? This seems to fix the issue on Windows but I still have the issue on Linux.

In node_modules/got/package.json:

{
  "browser": { "module-name": true/false }
}

If the module-name is false, webpack will ignore it in bundle. It should work for all the platform, as it's the behavior of webpack...

So should I add "decompress-response": true to both my project's pakcage.json and to got's package.json?

@ci010
Copy link
Collaborator

ci010 commented Mar 7, 2020

You just need remove browser field in got package.json. Adding it in your package.json won't fix the webpack bundle, since to bundle the got, webpack will follow the config in got's package json, not the root project.

@lukechu10
Copy link
Contributor Author

Fixed with PR #125

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