Azure / azure-functions-durable-js

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

Incorrect ReturnType of `DurableOrchestrationClient.getStatus` #486

Closed christianemmert closed 1 year ago

christianemmert commented 1 year ago

Describe the bug DurableOrchestrationClient interface states that getStatus() returns Promise<DurableOrchestrationStatus>. This is correct for instances that exist and weren't purged. But for purged instances getStatus() returns an empty string. This is highly unexpected and should be fixed.

Investigative information

To Reproduce Steps to reproduce the behavior:

const client = getClient(context);
const instanceId = await client.startNew("MY_ORCHESTRATOR");

await client.getStatus(instanceId) // -> returns DurableOrchestrationStatus object

await client.purgeInstanceHistory(instanceId)
await client.getStatus(instanceId) // -> returns ""

Expected behavior Interface of DurableOrchestrationClient.getStatus() represents the actual ReturnType of the method.

davidmrdavid commented 1 year ago

FYI @hossam-nasr

christianemmert commented 1 year ago

The problem is in https://github.com/Azure/azure-functions-durable-js/blob/2857fc579ba61b91673e5a4b259bf9ce2386bd1c/src/durableorchestrationclient.ts#L229. When no instance is found the client will return a status code of 404 as such response.data won't have the shape of DurableOrchestrationClient but rather an empty string.

hossam-nasr commented 1 year ago

Fixed by #512