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

The "Got" library failed to download electron behind local proxy #243

Open
lucascloarec opened this issue Apr 7, 2023 · 2 comments
Open
Assignees
Labels
🪲 bug Something isn't working

Comments

@lucascloarec
Copy link

lucascloarec commented Apr 7, 2023

Hi,
I use winfoom (https://github.com/ecovaci/winfoom) as a local proxy to connect my apps to our corporate proxy and I encounter the following error:

npm ERR! code 1
npm ERR! path C:\...\workspace\pki-gnokey\node_modules\electron
npm ERR! command failed
npm ERR! command C:\Program Files\Git\bin\bash.exe -c node install.js
npm ERR! RequestError: write EPROTO DC7D0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:355:
npm ERR!
npm ERR!     at ClientRequest.<anonymous> (C:\...\workspace\pki-gnokey\node_modules\got\dist\source\core\index.js:970:111)
npm ERR!     at Object.onceWrapper (node:events:628:26)
npm ERR!     at ClientRequest.emit (node:events:525:35)
npm ERR!     at ClientRequest.emit (node:domain:489:12)
npm ERR!     at origin.emit (C:\...\workspace\pki-gnokey\node_modules\@szmarczak\http-timer\dist\source\index.js:43:20)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:502:9)
npm ERR!     at TLSSocket.emit (node:events:525:35)
npm ERR!     at TLSSocket.emit (node:domain:489:12)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)

I have these environment variables:
ELECTRON_GET_USE_PROXY=true
GLOBAL_AGENT_HTTP_PROXY=http://127.0.0.1:3128
http_proxy=http://127.0.0.1:3128
https_proxy=http://127.0.0.1:3128

I have the impression that the SSL/TLS negotiation does not succeed because "got" forces the use of a too old version which is not compatible with my local proxy.
Also I don't encounter the problem when I use my own implementation of the Downloader interface, with axios instead of "got" :

import {Downloader} from "@electron/get/dist/esm/Downloader";
import * as fs from 'fs';
import axios, {AxiosRequestConfig, AxiosResponse} from "axios";
import * as Stream from "stream";


export class CustomDownloader implements Downloader<AxiosRequestConfig> {
    async download(url: string, path: string, options: AxiosRequestConfig = {}): Promise<void> {
        const writer = fs.createWriteStream(path)
        const response: AxiosResponse<Stream> = await axios.get(
            url, {
                ...options,
                responseType: 'stream'
            }
        )
        
        response.data.pipe(writer)
        return new Promise((resolve, reject) => {
            writer.on('finish', resolve)
            writer.on('error', reject)
        })
    }
}
import {download} from "@electron/get";
import {CustomDownloader} from "./custom-downloader";

const version = "24.0.0";

(async () => {
    const zipFilePath = await download(
        version,
        {
            downloader: new CustomDownloader(), // this script fails if this line is removed
        }
    );
    console.debug(zipFilePath)
    console.log("OK")
})()

My implementation of the Downloader interface is more basic than the current implementation that uses "got", it doesn't allow customization with the progress bar (is that really useful?), but I still suggest add it and allow to choose it (for example with the environment variable ELECTRON_GET_USE_AXIOS=true), or simply replace the current implementation.

@chinaxcy
Copy link

me

@BlackHole1 BlackHole1 self-assigned this Apr 14, 2023
@dsanders11 dsanders11 added the 🪲 bug Something isn't working label Aug 3, 2023
@bturnni
Copy link

bturnni commented Aug 27, 2024

There is any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants