Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround broken .NET 9.0 HttpSys linux packages #2673

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/ReverseProxy/Delegation/DummyHttpSysDelegator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Yarp.ReverseProxy.Delegation;

// Only used as part of a workaround for https://github.com/dotnet/aspnetcore/issues/59166.
internal sealed class DummyHttpSysDelegator : IHttpSysDelegator
{
public void ResetQueue(string queueName, string urlPrefix) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.Extensions.Logging;
using Yarp.ReverseProxy.Configuration;
using Yarp.ReverseProxy.Configuration.ConfigProvider;
using Yarp.ReverseProxy.Delegation;
using Yarp.ReverseProxy.Forwarder;
using Yarp.ReverseProxy.Management;
using Yarp.ReverseProxy.Routing;
Expand Down Expand Up @@ -52,10 +53,22 @@ public static IReverseProxyBuilder AddReverseProxy(this IServiceCollection servi
.AddActiveHealthChecks()
.AddPassiveHealthCheck()
.AddLoadBalancingPolicies()
.AddHttpSysDelegation()
.AddDestinationResolver()
.AddProxy();

if (OperatingSystem.IsWindows())
{
// Workaround for https://github.com/dotnet/aspnetcore/issues/59166.
// .NET 9.0 packages for Ubuntu ship a broken Microsoft.AspNetCore.Server.HttpSys assembly.
// Avoid loading types from that assembly on Linux unless the user explicitly tries to do so.
builder.AddHttpSysDelegation();
}
else
{
// Add a no-op delegator in case someone is injecting the interface in their cross-plat logic.
builder.Services.TryAddSingleton<IHttpSysDelegator, DummyHttpSysDelegator>();
}

services.TryAddSingleton<ProxyEndpointFactory>();

services.AddDataProtection();
Expand Down
Loading