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;