Azure-Samples / azure-search-openai-demo-csharp

A sample app for the Retrieval-Augmented Generation pattern running in Azure, using Azure Cognitive Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.
MIT License
555 stars 346 forks source link

Error on Hot Reload in latest version #214

Closed Coruscate5 closed 7 months ago

Coruscate5 commented 8 months ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [X] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Install project deps for local debugging. Attempt to Hot Reload any WASM page

Any log messages given by the failure

Error: The assembly 'XYZ.dll' cannot be edited or changed, because environment variable DOTNET_MODIFIABLE_ASSEMBLIES is set to '(null)', not 'Debug'

Expected/desired behavior

Hot Reload functions

OS and Version?

Windows 10

Versions

.NET 8 RC2

Mention any other details that might be useful

I cannot find any obvious way to intervene in this specific environment variable - setting it manually to Debug on either server side or client side doesn't seem to take.

There may be a way to inject into Blazor.start but I can't seem to find any docs on it.


Thanks! We'll be in touch soon.

Coruscate5 commented 8 months ago

This is very likely a .NET 8 RC2 bug - the env var is set to "debug" as expected for the mono src when the application loads, then somehow becomes unset during the hot reload process. Confirmed that other projects with .NET 7 and the exact same setup properly apply reload data to the running application.

Coruscate5 commented 7 months ago

It is not an RC2 bug as 8 GA is released - the fix is in the dependency ordering in Program.cs of the API. The corrected ending dependency ordering should be as follows:

app.UseHttpsRedirection();
app.UseOutputCache();

app.UseCors();
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();

app.UseRouting();

app.MapRazorPages();
app.MapControllers();
app.MapFallbackToFile("index.html");

app.MapApi();

app.Run();

The location of BlazorFrameworkFiles apparently determines the "Debug" value for DOTNET_MODIFIABLE_ASSEMBLIES - in certain dependency load orders, the environment variable is reset/removed so it just reads from WASM as "null".

My copy of this project is significantly forked from trunk here, so I guess I'll just close my own issue.

Coruscate5 commented 7 months ago

Per above, closing with workaround