From 99d78ad5ac761894f8e0bb193e2de855bddec031 Mon Sep 17 00:00:00 2001 From: Eric Doughty-Papassideris Date: Tue, 4 Mar 2025 17:48:46 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20back=20cli:=20minor=20fixes=20fo?= =?UTF-8?q?r=20output=20flush?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tdrive/backend/node/src/cli/lib/run-with-platform.ts | 6 +++++- .../backend/node/src/core/platform/services/admin/utils.ts | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tdrive/backend/node/src/cli/lib/run-with-platform.ts b/tdrive/backend/node/src/cli/lib/run-with-platform.ts index 4543b5f8..9ce0e440 100644 --- a/tdrive/backend/node/src/cli/lib/run-with-platform.ts +++ b/tdrive/backend/node/src/cli/lib/run-with-platform.ts @@ -8,6 +8,10 @@ import type { TdrivePlatform } from "../../core/platform/platform"; //TODO: When this gets used for all commands; update verboseDuringRun from search/index-all and move to root index // And consider moving print-config-summary call here. +const waitForFlush = (stream: NodeJS.WriteStream) => + new Promise((resolve, reject) => + stream.write("\r\n", err => (err ? reject(err) : resolve())), + ); /** * Start the platform and its services, run the command (passed as * the `handler` callback), then cleanly shut down the platform. @@ -36,7 +40,7 @@ export default async function runWithPlatform( process.exitCode = 1; } // Spinner seems to interrupt still buffered output otherwise - await new Promise(resolve => setTimeout(resolve, 200)); + await Promise.all([waitForFlush(process.stdout), waitForFlush(process.stderr)]); spinner.start("Platform: shutting down..."); await platform.stop(); spinner.succeed("Platform: shutdown"); diff --git a/tdrive/backend/node/src/core/platform/services/admin/utils.ts b/tdrive/backend/node/src/core/platform/services/admin/utils.ts index 07d2a9ba..497b432f 100644 --- a/tdrive/backend/node/src/core/platform/services/admin/utils.ts +++ b/tdrive/backend/node/src/core/platform/services/admin/utils.ts @@ -45,7 +45,6 @@ async function runInBatches( let batch; const result = [] as R[]; while ((batch = listCopy.splice(0, batchSize)).length) { - console.error("batch", batch); result.push(await map(batch)); } return result;