Azure / azure-functions-durable-js

JavaScript library for using the Durable Functions bindings
https://www.npmjs.com/package/durable-functions
MIT License
126 stars 46 forks source link

Activity's context's retryContext property is null when activity is being retried #598

Open guy-weavix opened 2 months ago

guy-weavix commented 2 months ago

Describe the bug When an orchestrator calls callActivityWithRetry with retry options, I would expect that the retryContext in the instance of InvocationContext passed into the activity's handler would not be null.

df.app.orchestration('TestOrchestrator', function* (context: OrchestrationContext) {
    context.log(`TestOrchestrator started`);

    const retryOptions = new df.RetryOptions(1_000, 3);
    context.log(JSON.stringify(retryOptions));
    const result = (yield context.df.callActivityWithRetry('TestActivity', retryOptions, ''));
    context.log(context, `TestOrchestrator completed`);
    return result;
});

df.app.activity('TestActivity', {
    handler: (text: string, context: InvocationContext): TestResult => {
        context.log(`Started activity with retryCount: ${context.retryContext?.retryCount}/${context.retryContext?.maxRetryCount}`);
        context.log(JSON.stringify(context));

        throw new Error(`boom`);
    },
});

When I run the orchestrator, I see the activity run 3 times as expected, but the retryContext is not present on the context passed into the activity.

Investigative information

To Reproduce Steps to reproduce the behavior:

Code above is a partial example.

A repo with full code example may be found here

Expected behavior I would expect that the retryContext on the instance of InvocationContext passed into the activity would not be null and would be populated with the current retry context.

Actual behavior The instance of the InvocationContext being passed into the activity has no retryContext even though the activity is being retried.