From 37c12084e2849bc4c36efb27d59a79c9f605718d Mon Sep 17 00:00:00 2001 From: tonyyang Date: Tue, 23 Jul 2024 11:19:14 +1000 Subject: [PATCH] fix: resolve the undefined case --- src/worker/orchestration-executor.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/worker/orchestration-executor.ts b/src/worker/orchestration-executor.ts index 9b0bad1..483547c 100644 --- a/src/worker/orchestration-executor.ts +++ b/src/worker/orchestration-executor.ts @@ -124,15 +124,12 @@ export class OrchestrationExecutor { // since we create an async iterator, we await the creation (so we can use await in the generator itself beside yield) const result = await fn(ctx, input); - // When a generator is passed this is - // [object AsyncGenerator] - const resultType = result?.toString(); - - const isAsyncGenerator = typeof result[Symbol.asyncIterator] === 'function'; + const isAsyncGenerator = typeof result?.[Symbol.asyncIterator] === 'function'; if (isAsyncGenerator) { // Start the orchestrator's generator function await ctx.run(result); } else { + const resultType = Object.prototype.toString.call(result); console.log(`An orchestrator was returned that doesn't schedule any tasks (type = ${resultType})`); // This is an orchestrator that doesn't schedule any tasks