Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Context deadline exceeded parsing csharp #107

Closed
erizocosmico opened this issue Jan 28, 2019 · 5 comments
Closed

Context deadline exceeded parsing csharp #107

erizocosmico opened this issue Jan 28, 2019 · 5 comments
Assignees
Labels

Comments

@erizocosmico
Copy link

Not sure if it's a C# driver, client-go or bblfshd issue so I just opened it here.

I'm using this script:

package main

import (
	"fmt"

	bblfsh "gopkg.in/bblfsh/client-go.v3"
)

const code = `
using System.Net;
using System.Net.Http.Headers;
using System.Net.Sockets;
using Microsoft.AspNetCore.Http;

namespace ProxyKit
{
    public static class XForwardedExtensions
    {
        public const string XForwardedFor = "X-Forwarded-For";
        public const string XForwardedHost = "X-Forwarded-Host";
        public const string XForwardedProto = "X-Forwarded-Proto";
        public const string XForwardedPathBase = "X-Forwarded-PathBase";

        /// <summary>
        ///     Applies X-Forwarded.* headers to the outgoing
        ///     header collection.
        /// </summary>
        /// <param name="outgoingHeaders">The outgoing HTTP request
        /// headers.</param>
        /// <param name="for">The client IP address.</param>
        /// <param name="host">The host of the request.</param>
        /// <param name="proto">The protocol of the incoming request.</param>
        public static void ApplyXForwardedHeaders(
            this HttpRequestHeaders outgoingHeaders,
            IPAddress @for,
            HostString host,
            string proto) 
            => ApplyXForwardedHeaders(outgoingHeaders, @for, host, proto, string.Empty);

        /// <summary>
        ///     Applies X-Forwarded.* headers to the outgoing header collection
        ///     with an additional PathBase parameter.
        /// </summary>
        /// <param name="outgoingHeaders">The outgoing HTTP request
        /// headers.</param>
        /// <param name="for">The client IP address.</param>
        /// <param name="host">The host of the request.</param>
        /// <param name="proto">The protocol of the incoming request.</param>
        /// <param name="pathBase">The base path of the incoming
        /// request.</param>
        public static void ApplyXForwardedHeaders(
            this HttpRequestHeaders outgoingHeaders,
            IPAddress @for,
            HostString host,
            string proto,
            PathString pathBase)
        {
            if (@for != null)
            {
                var forString = @for.AddressFamily == AddressFamily.InterNetworkV6
                    ? $"\"[{@for}]\""
                    : @for.ToString();
                outgoingHeaders.Add(XForwardedFor, forString);
            }

            if (host.HasValue)
            {
                outgoingHeaders.Add(XForwardedHost, host.Value);
            }

            if (!string.IsNullOrWhiteSpace(proto))
            {
                outgoingHeaders.Add(XForwardedProto, proto);
            }

            if (!string.IsNullOrWhiteSpace(pathBase))
            {
                outgoingHeaders.Add(XForwardedPathBase, pathBase);
            }
        }
    }
}
`

func main() {
	client, err := bblfsh.NewClient("0.0.0.0:9432")
	if err != nil {
		panic(err)
	}

	res, _, err := client.NewParseRequest().
		Language("csharp").
		Content(code).
		UAST()
	if err != nil {
		panic(err)
	}

	fmt.Println(res)
}

I'm running v2.11.0-drivers on a container and installed v0.2.0 of csharp driver.

Logs are:

time="2019-01-28T13:35:20Z" level=info msg="bblfshd version: v2.11.0 (build: 2018-12-12T23:31:48+0000)"
time="2019-01-28T13:35:20Z" level=info msg="initializing runtime at /var/lib/bblfshd"
time="2019-01-28T13:35:20Z" level=info msg="server listening in 0.0.0.0:9432 (tcp)"
time="2019-01-28T13:35:20Z" level=info msg="control server listening in /var/run/bblfshctl.sock (unix)"
time="2019-01-28T13:44:39Z" level=info msg="driver csharp installed "bblfsh/csharp-driver:v0.2.0""
time="2019-01-28T13:50:51Z" level=error msg="error selecting pool: unexpected error: context deadline exceeded"
time="2019-01-28T13:50:51Z" level=error msg="request processed content 2690 bytes error: unexpected error: context deadline exceeded" elapsed=5.2095507s language=csharp
time="2019-01-28T13:50:51Z" level=info msg="csharp-driver version: v0.2.0 (build: 2019-01-22T15:05:36Z)" id=01d2abm1kf0bgmhfjm8d1zz8j1 language=csharp
time="2019-01-28T13:50:51Z" level=info msg="server listening in /tmp/rpc.sock (unix)" id=01d2abm1kf0bgmhfjm8d1zz8j1 language=csharp
time="2019-01-28T13:51:37Z" level=warning msg="unable to allocate a driver instance: context deadline exceeded" language=csharp
time="2019-01-28T13:51:37Z" level=error msg="request processed content 2690 bytes error: context deadline exceeded" elapsed=5.0032111s language=csharp
@creachadair
Copy link
Contributor

I wonder if this is related to bblfsh/sdk#351, since 5 seconds is a fairly short timeout if we assume it has to include a possible driver startup.

@erizocosmico Is it possible you can try your request with a longer timeout to see if that helps?

@erizocosmico
Copy link
Author

I tried with 2 mins, 10 mins and 15 mins. Waits until the end of the timeout and then "context deadline exceeded".

@creachadair
Copy link
Contributor

Thanks for checking. This definitely sounds like a wedged driver.

@smacker
Copy link
Contributor

smacker commented Feb 6, 2019

Same issue but with newer bblfsh&driver: bblfsh/csharp-driver#25

@bzz
Copy link
Contributor

bzz commented Feb 14, 2019

Closing as this has been fixed and release in v2.11.7

@bzz bzz closed this as completed Feb 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants