From 74ed42c8e9057bdd8910d0eba03ea0b30b87e660 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Fri, 21 Aug 2020 22:12:22 +0300 Subject: Gate stream.pipeline workaround on fixed versions of node --- editors/code/src/net.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'editors') diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts index 681eaa9c9..5eba2728d 100644 --- a/editors/code/src/net.ts +++ b/editors/code/src/net.ts @@ -134,6 +134,14 @@ async function downloadFile( await pipeline(srcStream, destFileStream); + // Don't apply the workaround in fixed versions of nodejs, since the process + // freezes on them, the process waits for no-longer emitted `close` event. + // The fix was applied in commit 7eed9d6bcc in v13.11.0 + // See the nodejs changelog: + // https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V13.md + const [, major, minor] = /v(\d+)\.(\d+)\.(\d+)/.exec(process.version)!; + if (+major > 13 || (+major === 13 && +minor >= 11)) return; + await new Promise(resolve => { destFileStream.on("close", resolve); destFileStream.destroy(); -- cgit v1.2.3