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

[BUG]: Cannot download electron #1156

Closed
BlackHole1 opened this issue Aug 8, 2022 · 4 comments · Fixed by #1159
Closed

[BUG]: Cannot download electron #1156

BlackHole1 opened this issue Aug 8, 2022 · 4 comments · Fixed by #1159
Labels
🪲 bug Something isn't working

Comments

@BlackHole1
Copy link
Member

BlackHole1 commented Aug 8, 2022

During the download, I found that SHASUMS256.txt was a bunch of useless strings, causing the checksum to fail.

image
image

1.mp4

I have confirmed through git bisect start HEAD 3aa1e64 that the problem is caused by #1109 PR. But it is not clear why this is the case.

CC: @erickzhao @dsanders11 @aryanshridhar

@codebytere codebytere added the 🪲 bug Something isn't working label Aug 8, 2022
@BlackHole1
Copy link
Member Author

Additions from @aryanshridhar :

I am only able to reproduce this when I set the electron mirrors to CHINA under settings.
(It works fine if I set it to DEFAULT)

@BlackHole1
Copy link
Member Author

BlackHole1 commented Aug 8, 2022

I used the following code for the simulation but could not reproduce it.

const fs = require("fs");
const got = require("got");
const url = "https://npmmirror.com/mirrors/electron/v19.0.6/SHASUMS256.txt";
const gotOptions = {
    timeout: {
        connect: 15000,
        lookup: 15000,
        response: 15000,
        socket: 15000,
    },
}
const targetFilePath = "/Users/black-hole/1/SHASUMS256.txt";
const writeStream = fs.createWriteStream(targetFilePath);
const downloadStream = got.stream(url, gotOptions)

downloadStream.on('downloadProgress', async (progress) => {
    console.log(progress);
});
downloadStream.on('error', error => {
    if (writeStream.destroy) {
        writeStream.destroy(error);
    }
    console.error("download error", error);
});
writeStream.on('error', error => {
    console.log("file error", error);
});
writeStream.on('close', () => {
    console.log("close")
});

downloadStream.on("data", data => {
    console.log(data.toString());
})

downloadStream.pipe(writeStream);

image

Even if I put the code in devtools and execute it, it works fine.

image

@BlackHole1
Copy link
Member Author

BlackHole1 commented Aug 8, 2022

I know what the content represents now. This is gzip content. Now it's just a matter of determining why gzip decompression is not being performed here to see what the problem is.

@BlackHole1
Copy link
Member Author

BlackHole1 commented Aug 8, 2022

This was a bug in got that has been fixed in the new version of got, I will submit a PR for electron/get tomorrow

See: sindresorhus/got#1105 / sindresorhus/got#945

This bug is only triggered in the electron-renderer and when Webpack is packaged.

This also explains why the code I wrote to reproduce the problem was not reproducible

Fuck. It took me a whole day to fix this problem.

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

Successfully merging a pull request may close this issue.

2 participants