Skip to content

dotnet watch doesn't restart server on lambda return type change #48515

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

Open
denis-kralj-codesignal opened this issue Apr 16, 2025 · 0 comments
Labels
Area-Watch untriaged Request triage from a team member

Comments

@denis-kralj-codesignal
Copy link

denis-kralj-codesignal commented Apr 16, 2025

SDK version

9.0.203

Environment

MacOS 15.4
Apple M4

Reproduction

  1. Call dotnet new web
  2. Call dotnet watch run --non-interactive and open the local server in a browser
  3. change the return type of the default / GET handler (e.g. from app.MapGet("/", () => "Hello World!"); to app.MapGet("/", () => 1); and save the file
  4. refresh the page

Expectation

Step 3 detects the change as a "rude edit" and restarts the application, step 4 shows the new output in the browser

Reality

Step 3 detects the edit and writes this output to the console:

dotnet watch ⌚ File updated: ./Program.cs
dotnet watch 🔥 [dotnet (net9.0)] Hot reload succeeded.

Step 4 fails and the console gets this error message:

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.Runtime.CompilerServices.HotReloadException: Attempted to invoke lambda or local function with an unsupported change made while the application is running: /Users/denis/git/dotnet/Program.cs(4,17): error ENC0054: Changing the return type of lambda requires restarting the application.
         at Program.<>c.<<Main>$>b__0_0()
         at lambda_method1(Closure, Object, HttpContext)
         at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

Additional info

This behavior was behaving in line with expectations on SDK version 6.0.400, even without the --non-interactive flag

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Request triage from a team member labels Apr 16, 2025
@jjonescz jjonescz transferred this issue from dotnet/roslyn Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Watch untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

2 participants