freshworks-developers / request-method-samples

Sample codes to demonstrate making API calls using Request Method
7 stars 7 forks source link

Clarifications - Timeout option #17

Closed sabatale closed 1 year ago

sabatale commented 1 year ago

Hello,

We just wanted some clarifications around the Freshteam timeout as we're getting 502 errors with not much explanation other than the following in fdk.log: 0400 [debug] (request.js) request came back with error as ESOCKETTIMEDOUT.

The official documentation refers to REQUEST_TIMEOUT=10000 fdk run. For CMD Windows, the equivalent would be set REQUEST_TIMEOUT=10000 before running fdk run. But we don't see a difference, and the request stills ends at around 5.2sec. Is this still accurate? And that's only for local testing anyway.

Now, we're using fdk 9.0.2 with request templates. From what we can see in this repo, the correct way to set a timeout for both local testing and production would be to add { "options": "timeout": 10 } to our requests.json for each call. However we get the following error in CLI: must NOT have additional properties 'timeout' in config/requests.json (from this link). Is this the correct way to do it?

@Saif-Shines @kaustavdm

Thanks!


E.g.,

    "myPost": {
      "schema": {
        "method": "POST",
        "host": "abc",
        "path": "<%= context.urlpath %>",
        "headers": {
          "Authorization": "Bearer <%= iparam.apikey %>",
          "Content-Type": "application/json"
        }
      },
      "options": {
        "maxAttempts": 1,
        "retryDelay": 1000,
        "timeout": 10
      }
    }
    const response = await client.request.invokeTemplate("myPost", {
          context: {
            "id": id
          },
          cache: false,
          ttl: 70000,
          body: JSON.stringify(body)
      })
      .catch(function(error) {
        return myErrorHandling(error);
      });
Saif-Shines commented 1 year ago

Now, we're using fdk 9.0.2 with request templates. From what we can see in this repo, the correct way to set a timeout for both local testing and production would be to add { "options": "timeout": 10 } to our requests.json for each call.

Thanks for creating this issue @sabatale . Just in case you know, can you share any link to documentation or another source where this is documented? I must be unaware.

sabatale commented 1 year ago

I took it directly from the user guide here https://github.com/freshworks-developers/request-method-samples/blob/e26bed8585c5ce44064933f4864f99b30df0b6b2/UserGuide.md?plain=1#L248 but this may have changed since the beta?

Can you confirm there is no way to set a timeout manually?

Saif-Shines commented 1 year ago

The timeout option is available for local testing. We found some users using high latency systems during their development, so this configuration helped app developers succeed in their local development scenarios.

However in production, the only is to raise a request with the Freshworks team at dev-assist.freshworks.com

sabatale commented 1 year ago

Unfortunately we still get an error stating there is a timeout, no matter what we do. We'll open a ticket. Thanks!