Azure / Azure/azure-functions-durable-js

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

Open
#598 1 comment 0 reactions 0 assignees View on GitHub
P2
Dominant language
TypeScript
Stars
142
Forks
66
Avg merge
3d 19h
Merged PRs (30d)
4

Description

**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.

```Typescript
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**

- durable-functions npm module version: 3.1.0
- Language (JavaScript/TypeScript) and version: Typescript 4.0.0
- Node.js version: 18.0

**To Reproduce**
Steps to reproduce the behavior:

Code above is a partial example.

A repo with full code example may be found [here](https://github.com/guy-weavix/durable-functions-retry-example)

**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.

Contributor guide

Open the contributing guide

Research direction

Start with the linked durable-functions-retry-example repository and run the TypeScript reproduction using callActivityWithRetry and the activity InvocationContext. Trace how retry attempts are passed into the activity, then verify that retryContext reports the current retry count and maximum retry count across the three attempts.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.