Stack Overflow .NET 9 Response Compression when builder wrapper references IConfiguration/AppSettings #112018
Labels
needs-area-label
An area label is needed to ensure this gets routed to the appropriate area owners
Description
I've been working on upgrading a Blazor 7 wasm app to Blazor 9 web app. I came across a problem deploying the Blazor 9 app to IIS. The worker process would start for a few seconds then terminate with no http response. The issue only showed up when deploying from VS 2022 using the release build. If I deployed as a debug build the site would come up. Event Viewer didn't give much to go on for specifically what the error was except that the coreclr.dll was terminating. I turned on stdout in the web.config and the stack trace shows a stack overflow in relation to using the UseResponseCompression Middleware. What is odd is that the default usage of UseResponseCompression works, but if I want the usage to be controlled by a boolean in the appSettings by wrapping UseResponseCompression in a utility that reads the boolean from appSettings using IConfiguration it causes a stack overflow with the middleware. I'm attaching the stdout I see when using a wrapper for UseResponseCompression. I'll include the Service collection setup and the differences between the builder implementations in the reproduction steps. There wasn't an issue with this in .NET 7 so I'm not sure if the behavior changed in .NET 8 or 9.
stdout_20250130212257_22228.log
Reproduction Steps
AppSettings.json snippet
Service Collection Setup
Application Builder usage
Expected behavior
not throw an exception when using response compression
Actual behavior
The app pool terminates after a few seconds. The stdout from the app pool worker process is in the attachment
Regression?
This was working in .NET 7. I'm not sure if .NET 8 was an issue. Our code migration went from Blazor 7 -> 9. We did intermediate changes to .NET 8 due to blazor breaking changes, but then just continued on to 9.
Known Workarounds
comment out our utility wrapper for UseResponseCompression builder extension usage in Program.cs or use built in aspnetcore UseResponseCompression without accessing appSettings via IConfiguration to determine if the compression middleware should be loaded.
Configuration
Blazor 9 web app w/ server/client/shared project structure
Deployed via MSDeploy to On-prem IIS server (v10.0.20348.1 - Win Server 2022 21H2)
App Pool - No Managed Code - Default App Pool Identity
Built in VS 2022 Pro with .NET 9.0.102 x64 (9.1.224.61103)
Tried chrome from Win10 Pro x64 22H2, also tried from chrome on hosting server
Other information
dotnet --info output
The text was updated successfully, but these errors were encountered: