`writeFileListToStream` might hang when the writable stream becomes full (asar does not work between Node 15.2.0 and 15.4.0)
See original GitHub issueThis problem occurs when using node@15.2+ under Linux (Pop!_OS 20.10). Also tested on Mac OS 11.1 (node 15.1, 15.2 and 15.4) but no problem there. EDIT: Was able to reproduce this on the Mac setup. Might just be that the Macbook is to slow to trigger this problem reliably…
This might be the relevant change in node https://github.com/nodejs/node/pull/35348.
This is reproducible (at least on my machine) in my repository https://github.com/weedz/git-good. Running the command
$ npx electron-forge package
finishes when using node@15.1, but it hangs when using node@15.2 (also tested with version 15.4).
I then changed writeFileListToStream
to wait for out.writableNeedDrain
to become false. Now electron-forge package
finishes when using node@15.2, but this could probably be solved in a better way…
+ function sleep(ms) {
+ return new Promise((resolve, reject) => setTimeout(resolve, ms));
+ }
const writeFileListToStream = async function (dest, filesystem, out, list, metadata) {
for (const file of list) {
+ while (out.writableNeedDrain) {
+ await sleep(10);
+ }
if (file.unpack) { // the file should not be packed into archive
const filename = path.relative(filesystem.src, file.filename)
await copyFile(`${dest}.unpacked`, filesystem.src, filename)
} else {
await streamTransformedFile(file.filename, out, metadata[file.filename].transformed)
}
}
return out.end()
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top GitHub Comments
This issue has now been fixed in https://github.com/nodejs/node/pull/36563
For the record, the affected versions of Node.js were 15.2.0 through 15.4.0 inclusive. The fix mentioned was released in Node.js 15.5.0.