Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

durable function Http starter function failed #175

Closed
andyzhu opened this issue Apr 4, 2020 · 7 comments
Closed

durable function Http starter function failed #175

andyzhu opened this issue Apr 4, 2020 · 7 comments

Comments

@andyzhu
Copy link

andyzhu commented Apr 4, 2020

Error when try to the sample code:

const df = require("durable-functions");

module.exports = async function (context, req) {
const client = df.getClient(context);
const instanceId = await client.startNew(req.params.functionName, undefined, req.body);

context.log(`Started orchestration with ID = '${instanceId}'.`);

return client.createCheckStatusResponse(context.bindingData.req, instanceId);

};

The above highlighted code cause the following error

2020-04-04T02:24:40.434 [Information] Executing 'Functions.HttpStart' (Reason='This function was programmatically called via the host APIs.', Id=7dd0fb95-dd62-4781-a002-3ef44620aaad)
2020-04-04T02:24:50.700 [Error] Executed 'Functions.HttpStart' (Failed, Id=7dd0fb95-dd62-4781-a002-3ef44620aaad)
Result: Failure
Exception: Error: The operation failed with an unexpected status code: 500. Details: {"Message":"Something went wrong while processing your request","ExceptionMessage":"Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.","ExceptionType":"System.InvalidOperationException","StackTrace":" at Microsoft.AspNetCore.Server.IIS.Core.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 count)\r\n at Microsoft.AspNetCore.Server.IIS.Core.WrappingStream.Read(Byte[] buffer, Int32 offset, Int32 count)\r\n at System.Net.Http.DelegatingStream.Read(Byte[] buffer, Int32 offset, Int32 count)\r\n at System.IO.StreamReader.ReadBuffer(Span1 userBuffer, Boolean& readToUserBuffer)\r\n at System.IO.StreamReader.ReadSpan(Span1 buffer)\r\n at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)\r\n at Newtonsoft.Json.JsonTextReader.ReadData(Boolean append, Int32 charsRequired)\r\n at Newtonsoft.Json.JsonTextReader.ParseValue()\r\n at Newtonsoft.Json.JsonTextReader.Read()\r\n at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)\r\n at Microsoft.Azure.WebJobs.Extensions.DurableTask.HttpApiHandler.HandleStartOrchestratorRequestAsync(HttpRequestMessage request, String functionName, String instanceId) in C:\GitHub\azure-functions-durable-extension\src\WebJobs.Extensions.DurableTask\HttpApiHandler.cs:line 490\r\n at Microsoft.Azure.WebJobs.Extensions.DurableTask.HttpApiHandler.HandleRequestAsync(HttpRequestMessage request) in C:\GitHub\azure-functions-durable-extension\src\WebJobs.Extensions.DurableTask\HttpApiHandler.cs:line 152"}
Stack: Error: The operation failed with an unexpected status code: 500. Details: {"Message":"Something went wrong while processing your request","ExceptionMessage":"Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.","ExceptionType":"System.InvalidOperationException","StackTrace":" at Microsoft.AspNetCore.Server.IIS.Core.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 count)\r\n at Microsoft.AspNetCore.Server.IIS.Core.WrappingStream.Read(Byte[] buffer, Int32 offset, Int32 count)\r\n at System.Net.Http.DelegatingStream.Read(Byte[] buffer, Int32 offset, Int32 count)\r\n at System.IO.StreamReader.ReadBuffer(Span1 userBuffer, Boolean& readToUserBuffer)\r\n at System.IO.StreamReader.ReadSpan(Span1 buffer)\r\n at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)\r\n at Newtonsoft.Json.JsonTextReader.ReadData(Boolean append, Int32 charsRequired)\r\n at Newtonsoft.Json.JsonTextReader.ParseValue()\r\n at Newtonsoft.Json.JsonTextReader.Read()\r\n at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)\r\n at Microsoft.Azure.WebJobs.Extensions.DurableTask.HttpApiHandler.HandleStartOrchestratorRequestAsync(HttpRequestMessage request, String functionName, String instanceId) in C:\GitHub\azure-functions-durable-extension\src\WebJobs.Extensions.DurableTask\HttpApiHandler.cs:line 490\r\n at Microsoft.Azure.WebJobs.Extensions.DurableTask.HttpApiHandler.HandleRequestAsync(HttpRequestMessage request) in C:\GitHub\azure-functions-durable-extension\src\WebJobs.Extensions.DurableTask\HttpApiHandler.cs:line 152"}
at DurableOrchestrationClient.createGenericError (D:\home\site\wwwroot\node_modules\durable-functions\lib\src\durableorchestrationclient.js:587:16)
at DurableOrchestrationClient. (D:\home\site\wwwroot\node_modules\durable-functions\lib\src\durableorchestrationclient.js:401:44)
at Generator.next ()
at fulfilled (D:\home\site\wwwroot\node_modules\durable-functions\lib\src\durableorchestrationclient.js:4:58)
at processTicksAndRejections (internal/process/task_queues.js:94:5)

@ghost ghost added the Needs: Triage 🔍 label Apr 4, 2020
@anthonychu
Copy link
Member

@andyzhu Can you add an app setting named FUNCTIONS_V2_COMPATIBILITY_MODE, set it to true, and try again? In some environments, the Durable Functions extension is an older version and conflicts with the Azure Functions V3 host.

Can you let us know what sample you're trying and we can look into fixing it? For now, the simplest fix is the setting above.

There's a bit more information about this on the quickstart. It's a point-in-time problem that we hope will be addressed soon. Sorry about that.

@andyzhu
Copy link
Author

andyzhu commented Apr 4, 2020

i am using the azure portal to try out the durable function, where do I set the FUNCTIONS_V2_COMPATIBILITY_MODE? in functions.json file? if so , how?

I am actually follow the instruction on Azure Learn, @

https://docs.microsoft.com/en-us/learn/modules/create-long-running-serverless-workflow-with-durable-functions/4-exercise-create-a-workflow-using-durable-functions

@anthonychu
Copy link
Member

@andyzhu Thanks. We’ll get that updated. You can configure the setting like this: https://docs.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings#settings

@Dc9894
Copy link

Dc9894 commented Apr 10, 2020

@anthonychu I did try with the setting set to true, and it keeps failing. There is a workaround to this issue by changing the functions version to ~2 and enabling synchronous operations.

@Dc9894
Copy link

Dc9894 commented Apr 10, 2020

Found that looking at the durableorchestrationclient.ts which contains the startNew method, it seems that the problem is with a synchronous operation performed by the axios library, in durableorchestrationclient.ts line 606:

const response = await this.axiosInstance.post(requestUrl, input !== undefined ? JSON.stringify(input) : "");

When you pass undefined as the second parameter, the Exception InvalidOperationException is thrown by the SDK.

If you pass anything else, an empty string, null, etc, the exercise code will run without problems.

I suppose that if you change this to always call JSON.stringify the input it would work correctly. #176

Also look at the starkoverflow discussion

@andyzhu
Copy link
Author

andyzhu commented Apr 12, 2020

I found out how to change the setting to enable v2 support, MSFT also took notes to correct their tutorial in the future. i am closing the issue.

@andyzhu andyzhu closed this as completed Apr 12, 2020
@andyzhu
Copy link
Author

andyzhu commented Apr 12, 2020

I found out how to change the setting to enable v2 support, MSFT also took notes to correct their tutorial in the future. i am closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants