Skip to content

Timeout/Fail Issue when calling Client Functions #463

@chasse20

Description

@chasse20

Example:
I work for a large company that utilizes DocuSign in a production environment. When calling the TemplatesApi.GetAsync method, a rare timeout error can occur after the default 30 minutes have expired if something went wrong during this process. I believe this isn't being handled properly all the way to the root call in SystemNetHttpClient.cs:

https://github.com/docusign/docusign-esign-csharp-client/blame/master/sdk/src/DocuSign.eSign/Client/SystemNetHttpClient.cs#L35

public DocuSignResponse SendRequest(DocuSignRequest request)
{
    CancellationTokenSource cts = new CancellationTokenSource();
    Task<DocuSignResponse> t = Task.Run(async () => await SendRequestAsync(request, cts.Token));
    t.Wait();
    return t.Result;
}

Running the Task.Run is a dangerous/bad practice when this can simply be awaited normally. By not passing a CancellationToken down the method chain, we have no opportunity for our API to manually cancel anything running. Also this may lead to spawning threads/exhaustion in a high I/O environment like our API integration.

A better and safer implementation may be:

public DocuSignResponse SendRequest(DocuSignRequest request, CancellationToken token)
{
        return SendRequestAsync(request, token).GetAwaiter().GetResult();
}

at that point it would be best to just call SendRequestAsync directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions