From 9cd3aa943af3fe0ca7e784177067a5542e76973b Mon Sep 17 00:00:00 2001 From: Seweryn Kras Date: Thu, 23 Nov 2023 15:15:01 +0100 Subject: [PATCH] chore: change multi command endstream example to avoid terminating the executor mid-execution --- .../working-with-results/multi-command-endstream.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/docs-examples/examples/working-with-results/multi-command-endstream.mjs b/examples/docs-examples/examples/working-with-results/multi-command-endstream.mjs index f68600b3d..3d187092a 100644 --- a/examples/docs-examples/examples/working-with-results/multi-command-endstream.mjs +++ b/examples/docs-examples/examples/working-with-results/multi-command-endstream.mjs @@ -6,7 +6,7 @@ import { TaskExecutor } from "@golem-sdk/golem-js"; yagnaOptions: { apiKey: "try_golem" }, }); - const result = await executor.run(async (ctx) => { + await executor.run(async (ctx) => { const res = await ctx .beginBatch() .uploadFile("./worker.mjs", "/golem/input/worker.mjs") @@ -17,6 +17,7 @@ import { TaskExecutor } from "@golem-sdk/golem-js"; res.on("data", (result) => console.log(result)); res.on("error", (error) => console.error(error)); - res.on("close", () => executor.shutdown()); + return new Promise((resolve) => res.on("close", resolve)); }); + await executor.shutdown(); })();