dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.44k stars 10.02k forks source link

Unexpected error: System.InvalidOperationException after Hot Reload #53492

Open vsfeedback opened 9 months ago

vsfeedback commented 9 months ago

This issue has been moved from a ticket on Developer Community.


I was working my way through the Blazor learn module on building a Connect Four app, when I got the following error dialog:

image.png

Hot Reload output window contents:

13:03 38.44 ConnectFour (Web server): Hot reload session started
13:09 59.47 ConnectFour (Web server): Hot reload session complete
13:13 21.93 ConnectFour (Web server): Hot reload session started
13:17 48.48 ConnectFour (Web server): Sending updates to running application
13:17 48.50 Changes were successfully applied.
13:17 48.89 ConnectFour (Web server): Updates applied successfully
13:17 48.90 ConnectFour: Refreshing web browser
13:22 02.89 ConnectFour (Web server): Sending updates to running application
13:22 02.89 Changes were successfully applied.
13:22 03.01 ConnectFour (Web server): Updates applied successfully
13:22 03.01 ConnectFour: Refreshing web browser
13:32 03.98 ConnectFour (Web server): Sending updates to running application
13:32 03.98 Changes were successfully applied.
13:32 03.99 ConnectFour (Web server): Updates applied successfully
13:32 03.99 ConnectFour: Refreshing web browser
15:59 18.53 ConnectFour (Web server): Sending updates to running application
15:59 18.53 Changes were successfully applied.
15:59 18.59 ConnectFour (Web server): Updates applied successfully
15:59 18.59 ConnectFour: Refreshing web browser
15:59 18.59 ConnectFour: Refreshing the web browser failed. You may need to manually refresh the web browser to see the changes: The request sent to the browser failed: Web socket connection to the browser has been closed:  Web socket connection to the browser has been closed: 
15:59 20.99 No changes were found.
16:00 04.10 ConnectFour (Web server): Sending updates to running application
16:00 04.10 Changes were successfully applied.
16:00 04.13 ConnectFour (Web server): Updates applied successfully
16:00 04.13 ConnectFour: Refreshing web browser
16:00 12.57 ConnectFour (Web server): Hot reload session complete
16:00 28.93 ConnectFour (Web server): Hot reload session started
16:03 37.95 ConnectFour (Web server): Hot reload session complete
16:03 49.44 ConnectFour (Web server): Hot reload session started
16:05 27.35 ConnectFour (Web server): Hot reload session complete
16:07 47.48 ConnectFour (Web server): Hot reload session started
12:21 08.25 ConnectFour (Web server): Sending updates to running application
12:21 08.25 Changes were successfully applied.
12:21 08.55 ConnectFour (Web server): Updates applied successfully
12:21 08.55 ConnectFour: Refreshing web browser
12:21 08.55 ConnectFour: Refreshing the web browser failed. You may need to manually refresh the web browser to see the changes: The request sent to the browser failed: Web socket connection to the browser has been closed:  Web socket connection to the browser has been closed: 
12:21 34.06 ConnectFour (Web server): Sending updates to running application
12:21 34.06 Changes were successfully applied.
12:21 34.20 ConnectFour (Web server): Updates applied successfully
12:21 34.20 ConnectFour: Refreshing web browser
12:21 34.21 ConnectFour: Refreshing the web browser failed. You may need to manually refresh the web browser to see the changes: The request sent to the browser failed: Web socket connection to the browser has been closed:  Web socket connection to the browser has been closed: 
12:21 48.67 ConnectFour (Web server): Sending updates to running application
12:21 48.67 Changes were successfully applied.
12:21 48.68 ConnectFour (Web server): Updates applied successfully
12:21 48.68 ConnectFour: Refreshing web browser
12:21 48.68 ConnectFour: Refreshing the web browser failed. You may need to manually refresh the web browser to see the changes: The request sent to the browser failed: Web socket connection to the browser has been closed:  Web socket connection to the browser has been closed: 
12:22 32.53 An unexpected error has occurred, any pending updates have been discarded.

Possible related is that I was resuming my work after leaving the app running overnight. Maybe the connection to the browser timed out?


Original Comments

Feedback Bot on 1/16/2024, 05:44 PM:

(private comment, text removed)


Original Solutions

(no solutions)

mkArtakMSFT commented 9 months ago

We assume that this happened due to the WebSocket connection being terminated after the browser tab stayed open for a long time. Simply restarting the debug session should be a good way around this.

At the moment we have no functionality for restoring dropped WebSocket connection, so we may consider adding such functionality in the future.

mkArtakMSFT commented 9 months ago

Looks like we've received a similar feedback but for a situation, where the session didn't stay open long: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1900883