Azure / Azure/azure-functions-durable-js
DurableOrchestrationStatus constructor sets this.history with init.history instead of init.historyEvents
- Dominant language
- TypeScript
- Stars
- 142
- Forks
- 66
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 4
Description
**Describe the bug**
When calling `durableClient.getStatus(, { showHistory: true })`, `history` is not returned on response. While debugging, `DurableOrchestarationStatus`'s constructor does:
```js
// init.history does not exist on init but historyEvents does and contains the history data
this.history = init.history
```
**Investigative information**
- Durable Functions extension version: 1.16.1
- durable-functions npm module version: 3.1.0
- Language (JavaScript/TypeScript) and version: typescript 4.9.5
- Node.js version: 20.17.0
Additional:
- Azure Functions Core Tools: 4.0.5801
- Azure Runtime Version: 4.34.1.22669
***If deployed to Azure App Service***
- Timeframe issue observed: N/A
- Function App name: N/A
- Function name(s): N/A
- Region: N/A
- Orchestration instance ID(s): N/A
> If you don't want to share your Function App name or Functions names on GitHub, please be sure to provide your Invocation ID, Timestamp, and Region - we can use this to look up your Function App/Function. Provide an invocation id per Function. See the [Functions Host wiki](https://github.com/Azure/azure-webjobs-sdk-script/wiki/Sharing-Your-Function-App-name-privately) for more details.
**To Reproduce**
1. VSCode + Function App VSCode extension + Azurite ([Official setup docs](https://learn.microsoft.com/en-us/azure/azure-functions/durable/quickstart-ts-vscode?pivots=nodejs-model-v4))
2. F1 > Azure Functions: Create Function > Durable Functions orchestrator > Give it a name (Ex: "Test")
3. Orchestrator code should be Microsoft's example boilerplate code. The output of the durable function orchestration should be:
```json
{
"name": "helloOrchestrator",
"instanceId": "6ba3f77933b1461ea1a3828c013c9d56",
"runtimeStatus": "Completed",
"input": "",
"customStatus": null,
"output": [
"Hello, Tokyo",
"Hello, Seattle",
"Hello, Cairo"
],
"createdTime": "2023-02-13T23:02:21Z",
"lastUpdatedTime": "2023-02-13T23:02:25Z"
}
```
5. F1 > Azure Functions: Create Function > HTTP trigger > Give it a name (Ex: GetOrchestrationStatus)
6. In `GetOrchestrationStatus.ts` (function made on step 5), copy-paste:
```ts
import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions';
import { getClient, input } from 'durable-functions';
export async function GetOrchestrationStatus(request: HttpRequest, context: InvocationContext): Promise {
const { instanceId } = request.params;
const client = getClient(context);
const instance = await client.getStatus(instanceId, { showHistory: true });
return { jsonBody: instance, status: 200 };
}
app.http('GetOrchestrationStatus', {
route: ínstances/{instanceId},
methods: ['GET','POST'],
authLevel: 'anonymous',
extraInputs: [input.durableClient()],
handler: GetOrchestrationStatus
});
```
7. `local.settings.json`:
```json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "node"
}
}
```
8. Hit `F5` to run and debug
9. Put a breakpoint on the return line on `GetOrchestrationStatus`
10. Run an orchestration by using some tool like [Yaak](https://yaak.app/) Ex: `http://localhost:7071/api/orchestrators/TestOrchestrator`
11. Copy the orchestration instance ID (`id` on response)
12. Now call the `GetOrchestrationStatus` Azure function: `http://localhost:7071/api/instances/`
13. Response from call from step 12 does not have the `history` key with events
**Expected behavior**
A clear and concise description of what you expected to happen.
`durableClient.getStatus(instanceId, { showHistory: true })` return value has a `history` key and data.
**Actual behavior**
A clear and concise description of what actually happened.
`durableClient.getStatus(instanceId, { showHistory: true })` return value does not return a `history` key nor data.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Known workarounds**
Provide a description of any known workarounds you used.
Directly modify `node_modules/durable-functions/lib/src/orchestrations/DurableOrchestrationStatus.js`'s constructor:
```diff
- this.history = init.history
+ this.history = init.historyEvents
```
1. Not recommended to modify node_modules
2. On package update, directory delete, or node_modules delete, changes will be eliminated
**Additional context**
- Development environment (ex. Visual Studio)
- Links to source
- Additional bindings used
- Function invocation IDs
Contributor guide
Research direction
Open lib/src/orchestrations/DurableOrchestrationStatus.js and inspect the constructor used by durableClient.getStatus with showHistory enabled. Follow the reproduction steps to verify the returned status includes the history data; done when history is populated from the available history events.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100