Navigating away while a Web Worker operation is running can sometimes cause an unhandled error in the browser console.
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
### What Happened
In the Blazor WebAssembly standalone and Interactive WebAssembly sample, clicking Run in Worker starts a 5-second worker operation. If you navigate from Counter to Weather before the operation finishes and then return to Counter, an error may appear in the browser console. This issue occurs randomly and is not consistently reproducible.
### Expected Behavior
When navigating away, the WebWorkerClient should be disposed or cancelled safely. Any running worker operation should complete, cancel, or fail gracefully without causing unhandled browser or Blazor errors. Returning to the Counter page should create a clean component instance.
### Steps To Reproduce
1. Install .NET SDK `11.0.100-preview.7.26381.103`
2. Clone the sample repository:
3. Open a terminal and navigate to the **BlazorWebWorkerStandalone** project folder.
4. Install the `dotnet-serve` tool (if it is not already installed):
```bash
dotnet tool install --global dotnet-serve
```
5. Publish the application:
```bash
dotnet publish -c Release
```
6. Navigate to the publish output directory:
```bash
cd bin\Release\net11.0\publish\wwwroot
```
7. Host the published application:
```bash
dotnet-serve -S
```
8. Open the localhost URL displayed in the terminal.
9. Open the **Counter** page.
10. Click **Run in Worker**.
11. Before the 5-second operation completes, navigate to the **Weather** page.
12. Navigate back to the **Counter** page.
13. Click anywhere on the page and wait for the original worker operation to complete.
14. Open **Browser DevTools → Console** and check for unhandled errors.
15. Repeat the steps multiple times, as the issue occurs intermittently.
### Evidence
- [ClientDisposalAndNavigationValidation_Fail.mp4](https://github.com/Vinoth2562000/BlazorWebWorkerValidation/blob/main/Evidence/Standalone%20WebAssembly/ClientDisposalAndNavigationValidation_Fail.mp4)
### Error Logs
- [Contains error log documents](https://github.com/Vinoth2562000/BlazorWebWorkerValidation/blob/main/Evidence/Error%20Logs/ClientDisposalAndNavigationValidation_Fail%20Error%20Log.log)
### Published Files
- [Contains published file documents](https://github.com/Vinoth2562000/BlazorWebWorkerValidation/tree/main/Evidence/Published%20Build%20Files/Release4/net11.0)
### Screenshot
### Observed Behavior
Disposing the `WebWorkerClient` and navigating away while a worker operation is still running can sometimes result in an unhandled browser console error.
### Exceptions (if any)
_No response_
### .NET Version
.NET SDK 11.0.100-preview.7.26381.103
### Anything else?
_No response_
Contributor guide
Research direction
Start with the Counter page and the WebWorkerClient disposal path in the linked Blazor WebAssembly sample, then reproduce the navigation sequence while watching Browser DevTools → Console and the provided error log. Done means navigating away during the five-second operation and returning to Counter no longer produces unhandled browser or Blazor errors, including across repeated intermittent runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, wasm
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100