Error: Choose either to return a promise or call 'done' when calling my durable entity

Zava 25 Reputation points
2023-03-07T21:08:57.76+00:00

Hello!

I am trying to call some operations defined in my durable entity from the orchestrator function, but when I do this I get the following error: 'Error: Choose either to return a promise or call 'done''

language: typescript

Orchestrator:

const entityId = new df.EntityId('temp-storage', 'temp-storage');
// ... my code to generate documents
yield context.df.callEntity(entityId, 'addDocuments', documents);

Entity

export default df.entity((context) => {
  const entityState = context.df.getState(() => ({
     ...
  })) as UniqueDataEntityState;

  switch (context.df.operationName) {
    case 'addDocuments': {
      entityState.documents.push(context.df.getInput());
      context.df.setState(entityState);
      break;
    }
    case 'get':
      context.df.return(entityState);
      break;
    default:
      break;
  }
});

The code is working but I want to get rid of this error. How can I do it?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,930 questions
0 comments No comments
{count} votes

Accepted answer
  1. MikeUrnun 9,777 Reputation points Moderator
    2023-03-10T06:41:03.39+00:00

    Hello @Zava - Thanks for reaching out on the MS Q&A!

    The error message appears to be harmless (other than messing up the logs) and doesn't keep your function from working as intended (which is consistent with your observation) - and it looks like there's an open bug that causes the error message: https://github.com/Azure/azure-functions-durable-js/issues/373

    Per the product group, the error message will get suppressed in one of the major releases (open PR here) soon (based on other high-priority items) and the following is mentioned here:

    It's worth noting that this bug is only about cleaning up the logs - the existing error doesn't actually block the function from working.

    I hope this is helpful and brings clarity to your questions, do let me know if you have any further questions on this matter.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Jaliya Udagedara 2,836 Reputation points MVP Volunteer Moderator
    2023-03-09T08:17:22.02+00:00

    Since this isn't async, you need to call context.done().

    And note: context.done method

    In 2.x, 3.x, and 4.x, the function should be marked as async even if there's no awaited function call inside the function, and the function doesn't need to call context.done to indicate the end of the function.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.