Azure-functions-host: [CustomHandler]Set HttpClient.Timeout property functionTimeout value

Created on 4 Sep 2020  路  3Comments  路  Source: Azure/azure-functions-host

Investigative information

Please provide the following:

  • Timestamp:2020-09-04 04:29:08.9819139
  • Function App version: 3.0.14287.0
  • Function App name: denofunc-lnx-c
  • Function name(s) (as appropriate): hello_world
  • Invocation ID: a98cceda-39f4-4acc-946e-d0ad732f0309
  • Region: West US 2

Repro steps

Provide the steps required to reproduce the problem:

  1. Deploy following HTTP Trigger function with deno custom handler using denofunc to Azure
    This is a simple HTTP trigger which returns 200 OK after 120 sec from receiving a request.
import { AzureFunctionsContext } from "../deps.ts";

const sleep = (milliseconds:number) => {
  return new Promise((res) => {
    setTimeout(() => {
      res();
    }, milliseconds);
  });
}

async function handler(context: AzureFunctionsContext) {
  await sleep(120000);
  context.res = {
    status: 200,
    body: `Welcome to deno ${Deno.version.deno} 馃 in Azure Functions 鈿★笍!!!`
  };
}

export default {
  handler,

  // Name of the function
  name: "hello_world",

  // By default, it's an HTTP function. For other functions, add a `metadata` property 
  // with the contents of function.json that describes the trigger and bindings.
  // https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-example
};
  1. Invoke the function, for example executing curl

Expected behavior

200 OK returns after 120 sec from receiving request

Actual behavior

500 Internal Server Error returns after 100 sec from the request

Provide a description of the actual behavior observed.

This issue can be reproduced Functions Core Tools @ 3.0.2798 on local environment.
image

Known workarounds

None.

Related information

Provide any related information

  • Programming language used: typescript (deno)
  • Bindings used: HTTP

This is similar issue as https://github.com/Azure/azure-functions-host/issues/6560

bug httpWorker

Most helpful comment

cc @yojagad @anthonychu

Thanks for reporting the issue.

By default, Timeout property on HttpClient is 100,00ms (10s).
https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout?view=netcore-3.1

We need to set the timeout on httpClient to functionTimeout value. Also, if invocation fails due to timeout on httpRequest, failure is raised as OperationCanceledException. This needs to be wrapped as inner exception to ensure function invocation failure reflects - FunctionTimeoutException

All 3 comments

cc @pragnagopa

cc @yojagad @anthonychu

Thanks for reporting the issue.

By default, Timeout property on HttpClient is 100,00ms (10s).
https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout?view=netcore-3.1

We need to set the timeout on httpClient to functionTimeout value. Also, if invocation fails due to timeout on httpRequest, failure is raised as OperationCanceledException. This needs to be wrapped as inner exception to ensure function invocation failure reflects - FunctionTimeoutException

Thanks @pragnagopa !

I'm looking forward to setting functionTimeout value for the httpClient.
Of course, I know there is no ETA for this preview feature

Is this httpClient you mentioned?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ladeak picture ladeak  路  3Comments

yvele picture yvele  路  3Comments

Alezis picture Alezis  路  4Comments

alaatm picture alaatm  路  4Comments

silencev picture silencev  路  3Comments