mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 23:30:41 +09:00
Use stream.finished for detecting end of streams
There are some corner cases with streams that cause them to not emit finish close or end events which in turn means that code liseting for these events directly may end up hanging forever. Use stream.finished to detect end of streams which will handle these cases correctly.
This commit is contained in:
1 parent
601ebba919
commit
170a3d3cf7
6 files changed
+51
-25
No files matched your search
@@ -15,6 +15,7 @@ const yargs = require("yargs");
|
||||
const { levels, logger, setLogLevel } = require("./logging");
|
||||
let dev = false;
|
||||
const scriptExt = process.platform === "win32" ? ".cmd" : "";
|
||||
const finished = util.promisify(stream.finished);
|
||||
|
||||
|
||||
const availablePlugins = [
|
||||
@@ -480,7 +481,7 @@ async function downloadLinuxServer() {
|
||||
const writeStream = fs.createWriteStream(tmpArchivePath);
|
||||
res.pipe(writeStream);
|
||||
|
||||
await events.once(res, "end");
|
||||
await finished(writeStream);
|
||||
|
||||
await fs.rename(tmpArchivePath, archivePath);
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user