ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.22k stars 743 forks source link

[Azure Functions] BananaCakePop UI no longer accessible #6765

Closed ebaldry-quest closed 2 weeks ago

ebaldry-quest commented 10 months ago

Is there an existing issue for this?

Product

Banana Cake Pop

Describe the bug

Currently running HotChocolate/Hotchocolate.AzureFunctions 12.22.2, but the same problem occurs with all other previous versions down to 12.12.1.

Attempting to run a simple GraphQL endpoint in C# Azure Functions v4. Same error is encountered whether I'm running it locally or in a cloud instance. When my /graphql/ endpoint is hit from the browser, previously the BananaCakePop UI would become visible immediately regardless of token status. A token would need to be included afterwards in order to receive schema information or to execute queries (since I'm using authorization). Today however, I am receiving a HTTP 500 error immediately upon visiting the endpoint through the browser with the following text:

System.Private.CoreLib: Exception while executing function: <myGraphQLEndpoint>. BananaCakePop.Middleware: The type initializer for 'BananaCakePop.Middleware.BananaCakePopCdnMiddleware' threw an exception. BananaCakePop.Middleware: Method not found: 'Void System.Net.Http.SocketsHttpHandler.set_ActivityHeadersPropagator(System.Diagnostics.DistributedContextPropagator)'.

Same errors are encountered using Edge and Chrome, from multiple computers and users, and from multiple cloud instances.

BCP was functioning normally the last time it was used, which is about a month ago. No code changes have been deployed to our repo since the last time this was functional. I've already tried other suggestions such as adding AllowIntrospection(), AllowAnonymous(), and setting Tool.ServeMode = GraphQLToolServeMode.Embedded, but no successes with any combination of these options.

The version of BananaCakePop.Middleware being used is 10.0.7 and its pulled in through HotChocolate.AspNetCore 12.22.2. If I manually include the latest version of BananaCakePop.Middleware 13.0.0 I still encounter the same failure at the same spot. (Please see the log output below for the stack trace at the time of exception.)

An important note: when using the BCP desktop app (latest stable version 13.0.0) the endpoint functions normally with no errors.

I don't see any code in your repo for BananaCakePopCdnMiddleware itself, so I have been unable to determine what changes if any may have resulted in this issue.

Steps to reproduce

  1. N/A

Relevant log output

{"The type initializer for 'BananaCakePop.Middleware.BananaCakePopCdnMiddleware' threw an exception."}
{"Method not found: 'Void System.Net.Http.SocketsHttpHandler.set_ActivityHeadersPropagator(System.Diagnostics.DistributedContextPropagator)'."}
   at BananaCakePop.Middleware.BananaCakePopCdnMiddleware..cctor()

Stack trace follows:    

HotChocolate.AspNetCore.dll!HotChocolate.AspNetCore.HttpGetMiddleware.InvokeAsync(Microsoft.AspNetCore.Http.HttpContext context) Line 62

HotChocolate.AspNetCore.dll!HotChocolate.AspNetCore.HttpMultipartMiddleware.InvokeAsync(Microsoft.AspNetCore.Http.HttpContext context) Line 60

HotChocolate.AspNetCore.dll!HotChocolate.AspNetCore.HttpPostMiddlewareBase.InvokeAsync(Microsoft.AspNetCore.Http.HttpContext context) Line 55
    HotChocolate.AzureFunctions.dll!HotChocolate.AzureFunctions.DefaultGraphQLRequestExecutor.ExecuteAsync(Microsoft.AspNetCore.Http.HttpRequest request) Line 30

Additional Context?

No response

Version

12.22.2

ebaldry-quest commented 10 months ago

My team has decided to just go through the desktop app moving forward and we will disable the web-based BCP UI in our GraphQL service. I'll leave this issue open though in case it is of value to anyone else.

ebaldry-quest commented 10 months ago

Also of note, I'm seeing the same error come up even if I have BananaCakePop disabled through configuration. Tool.Enable = false is still throwing exceptions for BananaCakePop.Middleware even though I would have expected that codepath to just be blocked altogether.

ebaldry-quest commented 10 months ago

It looks like BananaCakePop is being injected for Azure Functions regardless of the Tool settings:

https://github.com/ChilliCream/graphql-platform/blob/d72ad9dd1ef42f2714ca09733c7d64ea0fe115b2/src/HotChocolate/AzureFunctions/src/HotChocolate.AzureFunctions/Extensions/HotChocolateAzureFunctionServiceCollectionExtensions.cs#L104

I would expect the injection to only be done conditionally. It would be nice to be able to disable this injection because we do not want BCP at all. This would allow us to bypass whatever underlying reason is behind these web exceptions.

The BCP dependencies are all marked as internal, so I'm also unable to manually remove them from my service collection.

michaelstaib commented 10 months ago

AzureFunctions is not a good environment for GraphQL especially with the shift to the new model. We in general recommend people to move to Azure Container Apps as you have the same use based model but no restrictions. We are discussing dropping official support for AzureFunctions and leaving this to the community as it brings with it so many problems and limitations.

ebaldry-quest commented 10 months ago

@michaelstaib Thank you for the reply. We are considering moving into Container Apps, but that is a much larger project to take on for us. However the stack trace of the exceptions we're encountering are ultimately coming from HotChocolate.AspNetCore. Are you sure this is an issue that's specific to Azure Functions and would actually be resolved by using Container Apps instead?

glen-84 commented 2 weeks ago

I'm not able to reproduce this issue with HotChocolate.AzureFunctions 12.22.2 or 13.9.14 (no auth).

If you're still seeing this, then please add a link to a minimal reproduction of the issue.

ebaldry-quest commented 2 weeks ago

As I commented above earlier, we decided to just disable BananaCakePop.

glen-84 commented 2 weeks ago

Okay, I'll close this issue, but it should work.