Couldn't be able to continueAsNew a child workflow inside the same childWorkflow

This is the error I am getting

[childWorkflow(child-42423-1)] Child Workflow Errr ContinueAsNew: Workflow continued as new
    at eval (webpack-internal:///./node_modules/@temporalio/workflow/lib/workflow.js:651:19)
    at eval (webpack-internal:///./node_modules/@temporalio/workflow/lib/workflow.js:662:16)
    at Object.continueAsNew (webpack-internal:///./node_modules/@temporalio/workflow/lib/workflow.js:691:35)
    at childWorkflow (webpack-internal:///./dist/src/utils/schedule-workflow.js:183:26)
    at Script.runInContext (node:vm:139:12)
    at Object.runInContext (node:vm:289:6)
    at Proxy.<anonymous> (/mnt/d/officework/databashi-worker/node_modules/@temporalio/worker/lib/workflow/vm.js:62:46)
    at VMWorkflow.activate (/mnt/d/officework/databashi-worker/node_modules/@temporalio/worker/lib/workflow/vm.js:176:39)
    at handleRequest (/mnt/d/officework/databashi-worker/node_modules/@temporalio/worker/lib/workflow/workflow-worker-thread.js:45:47)
    at MessagePort.<anonymous> (/mnt/d/officework/databashi-worker/node_modules/@temporalio/worker/lib/workflow/workflow-worker-thread.js:79:38) {
  command: {
    workflowType: 'childWorkflow',
    arguments: [ [Object], [Object], [Object], [Object], [Object] ],
    headers: {},
    taskQueue: '3123',
    memo: undefined,
    searchAttributes: undefined,
    workflowRunTimeout: undefined,
    workflowTaskTimeout: undefined
  }
}

This is my code for creating child workflow

async function spawnChild(
  invocation: number,
  fields:any, 
  command: Command
) {
  const childWorkflowOpts = {
    workflowId: `${command.workflowId}-${invocation}`,
    cancellationType: wf.ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED,
    parentClosePolicy: wf.ParentClosePolicy.PARENT_CLOSE_POLICY_ABANDON,
  };

  return startChild(childWorkflow, {
    ...childWorkflowOpts,
    args: [command.workflowId, command.isCron, command.script, invocation, fields],
  });
}


Long story short… the spawn child method is creating a childWorkflow and function childWorkflow has continueAsNew childWorkflow, but I get the error. I am unable to understand the error and also how to resolve this issue

continueAsNew is implemented via throwing a special exception, you should let that exception propagate

1 Like

Thankyou, it worked!