runtime: Blazor Wasm Crashes if another wasm instance is running in the service worker.

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

My application loads another .NET Wasm instance in a service worker to perform offline processing. This causes the debugger to crash with

Microsoft.WebAssembly.Diagnostics.DevToolsProxy[0] DevToolsProxy::Run: Exception System.AggregateException: One or more errors occurred. (The remote party closed the WebSocket connection without completing the close handshake.)  ---> System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake.    at System.Net.WebSockets.ManagedWebSocket.ThrowIfEOFUnexpected(Boolean throwOnPrematureClosure)    at System.Net.WebSockets.ManagedWebSocket.EnsureBufferContainsAsync(Int32 minimumRequiredBytes, CancellationToken cancellationToken, Boolean throwOnPrematureClosure)    at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)    at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TResult](Memory`1 payloadBuffer, CancellationToken cancellationToken)    at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)    at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state) --- End of stack trace from previous location ---    at Microsoft.WebAssembly.Diagnostics.DevToolsProxy.ReadOne(WebSocket socket, CancellationToken token)    --- End of inner exception stack trace ---    at Microsoft.WebAssembly.Diagnostics.DevToolsProxy.Run(Uri browserUri, WebSocket ideSocket)

This makes it impossible to debug my application with the service worker running.

The wasm instance loaded in the service worker uses https://github.com/unoplatform/Uno.Wasm.Bootstrap

Expected Behavior

The debugger should not crash.

Steps To Reproduce

https://github.com/groogiam/dotnetruntime-76026-repro

Exceptions (if any)

No response

.NET Version

6.0.401

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Whoops, totally overlooked that step. That seems to have taken care of the issue. Thanks again!

@lewing @thaystg Great! Thanks for the info.

@thaystg Awesome! Thanks for implementing the fix so quickly.

Just posted the repro in the original comment.