electron-devtools-installer icon indicating copy to clipboard operation
electron-devtools-installer copied to clipboard

Unable to install react-developer-tools (unzip exits with code 9 "not found" due to HTTP-204 trying to download the crx)

Open nonchip opened this issue 3 years ago • 4 comments

code (from electron-react-boilerplate):

  const installer = require('electron-devtools-installer');
  const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS'];
// ... (some promise/catch/await magic) ...
  extensions.map((name) => installer.default(installer[name], forceDownload))

output:

Error: Exited with code 9
    at ChildProcess.<anonymous> (/home/kyra/dev/worst_story_engine/node_modules/cross-unzip/index.js:40:21)
    at ChildProcess.emit (events.js:210:5)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)

according to man unzip, code 9 is:

the specified zipfiles were not found.

patched some logging into cross-unzip by hand, it's trying to run:

unzip -o ~/.config/Electron/extensions/fmkadmapgofadopljbjfkapdkoienihi.crx -d ~/.config/Electron/extensions/fmkadmapgofadopljbjfkapdkoienihi

looked at that file:

$ file ~/.config/Electron/extensions/fmkadmapgofadopljbjfkapdkoienihi.crx
~/.config/Electron/extensions/fmkadmapgofadopljbjfkapdkoienihi.crx: empty

tried to manually remove it, exact same issue again. looks like somehow instead of e.g. 404ing or similar, the chrome servers just give you an empty file (or you somehow manage to drop the content instead of saving it, but i doubt that, utils.downloadFile looks sane), thus not triggering your Failed to fetch error.


Update:

peeled the url out of your code, curled it manually to see:

$ curl -v https://clients2.google.com/service/update2/crx\?response\=redirect\&x\=id%3Dfmkadmapgofadopljbjfkapdkoienihi%26uc\&prodversion\=32

[omitting lots of ssl/connection stuff here that's unrelated]

* Connected to clients2.google.com (172.217.18.110) port 443 (#0)
* Using HTTP2, server supports multi-use
> GET /service/update2/crx?response=redirect&x=id%3Dfmkadmapgofadopljbjfkapdkoienihi%26uc&prodversion=32 HTTP/2
> Host: clients2.google.com
> user-agent: curl/7.72.0
> accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 204
< content-security-policy: script-src 'report-sample' 'nonce-VQkaHQUCKKGpu5OepZ/IVg' 'unsafe-inline' 'strict-dynamic' https: http:;object-src 'none';base-uri 'self';report-uri https://csp.withgoogle.com/csp/clientupdate-aus/1
< cache-control: no-cache, no-store, max-age=0, must-revalidate
< pragma: no-cache
< expires: Mon, 01 Jan 1990 00:00:00 GMT
< date: Sun, 27 Sep 2020 08:36:37 GMT
< server: GSE
< alt-svc: h3-Q050=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
<
* Connection #0 to host clients2.google.com left intact

so yeah, getting a nice HTTP/2 204 (no content) with empty response, which you're not catching in downloadFile, if i had to take a wild guess i'd say google changed the URL and/or extension id (though https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi still seems valid).

note it actually did install the redux tools, so it just seems to be something about the react-devtools that's wrong

nonchip avatar Sep 27 '20 08:09 nonchip

I also experience this. Probably the culprit is cross-zip package. It's only a wild guess though. Need to check and confirm.

agungsb avatar Oct 06 '20 08:10 agungsb

I ended up using https://www.electronjs.org/docs/api/session#sesloadextensionpath and it worked fine. Great package anyway 👍

agungsb avatar Oct 06 '20 09:10 agungsb

I believe you just need to upgrade to version 3.1.1 which suppports crx version 3 downloads. It was fixed here: #140

esiegel avatar Oct 07 '20 08:10 esiegel

@esiegel Thanks! Update to 3.1.1 fixed the issue for me.

andyfaizan avatar Oct 24 '20 16:10 andyfaizan