diff --git a/examples/docs-examples/examples/working-with-results/single-command-fail.mjs b/examples/docs-examples/examples/working-with-results/single-command-fail.mjs index e4a92201c..d8a523fbb 100644 --- a/examples/docs-examples/examples/working-with-results/single-command-fail.mjs +++ b/examples/docs-examples/examples/working-with-results/single-command-fail.mjs @@ -4,7 +4,6 @@ import { TaskExecutor } from "@golem-sdk/golem-js"; const executor = await TaskExecutor.create({ package: "529f7fdaf1cf46ce3126eb6bbcd3b213c314fe8fe884914f5d1106d4", yagnaOptions: { apiKey: "try_golem" }, - isSubprocess: true, }); // there is a mistake and instead of 'node -v' we call 'node -w' diff --git a/examples/docs-examples/examples/working-with-results/single-command.mjs b/examples/docs-examples/examples/working-with-results/single-command.mjs index 1075c8dba..7a48cebf6 100644 --- a/examples/docs-examples/examples/working-with-results/single-command.mjs +++ b/examples/docs-examples/examples/working-with-results/single-command.mjs @@ -4,7 +4,6 @@ import { TaskExecutor } from "@golem-sdk/golem-js"; const executor = await TaskExecutor.create({ package: "529f7fdaf1cf46ce3126eb6bbcd3b213c314fe8fe884914f5d1106d4", yagnaOptions: { apiKey: "try_golem" }, - isSubprocess: true, }); const result = await executor.run(async (ctx) => await ctx.run("node -v")); diff --git a/examples/docs-examples/examples/working-with-results/worker.mjs b/examples/docs-examples/examples/working-with-results/worker.mjs new file mode 100644 index 000000000..accefceba --- /dev/null +++ b/examples/docs-examples/examples/working-with-results/worker.mjs @@ -0,0 +1 @@ +console.log("Hello World"); diff --git a/tests/examples/examples.test.ts b/tests/examples/examples.test.ts index eaf1460bf..9c464452b 100644 --- a/tests/examples/examples.test.ts +++ b/tests/examples/examples.test.ts @@ -29,9 +29,6 @@ async function test(cmd: string, path: string, args: string[] = [], timeout = 18 const timeoutId = setTimeout(() => { error = `Test timeout was reached after ${timeout} seconds.`; spawnedExample.kill(); - // for some reason the process doesn't exit after kill, it does so after I type enter - spawnedExample.stdin.write("\n"); - spawnedExample.stdin.end(); }, timeout * 1000); return new Promise((res, rej) => { spawnedExample.stdout?.on("data", (data: string) => { @@ -39,8 +36,10 @@ async function test(cmd: string, path: string, args: string[] = [], timeout = 18 if (criticalLogsRegExp.some((regexp) => data.match(regexp))) { error = `A critical error occurred during the test.`; spawnedExample.kill(); - spawnedExample.stdin.write("\n"); - spawnedExample.stdin.end(); + } + // for some reason, sometimes the process doesn't exit after Executor shut down + if (data.indexOf("Task Executor has shut down") !== -1) { + spawnedExample.kill("SIGKILL"); } }); spawnedExample.on("close", (code) => {