[PR #375] [CLOSED] JSDisconnectedException in RadzenDataGrid Dispose #2154

Open
opened 2026-01-29 18:17:29 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/radzenhq/radzen-blazor/pull/375
Author: @dxrdxr
Created: 2/16/2022
Status: Closed

Base: masterHead: master


📄 Description

As described in #373, in .Net 6.0, there is a race condition where the JSRuntime will become unavailable
before a component's Dispose is able to be called (may take upwards of 60 seconds). As a result, Blazor will throw a JSDisconnectedException on each subsequent call to JSRuntime.InvokeVoidAsync.

The fix is to wrap the calls in Dispose to catch JSDisconnectedException and set IsJSRuntimeAvailable to false.
Because JSRuntime.InvokeVoidAsync is in fact async, the code must await the result in order to catch exceptions.
This pattern of calling into the runtime in Dispose is in many components so a wrapper was created to handle the
common boilerplate code needed to wrap the component specific functionality.

The improvement is most notable in the DataGrid component which calls the runtime once per column, which may trigger 4-5 exceptions being thrown per column! After this fix the first exceptions are caught and further exceptions prevented.

This change in behavior is only observed in .Net 6.0, so as part of this fix a new Target was enabled and the associated changes were made.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/radzenhq/radzen-blazor/pull/375 **Author:** [@dxrdxr](https://github.com/dxrdxr) **Created:** 2/16/2022 **Status:** ❌ Closed **Base:** `master` ← **Head:** `master` --- ### 📄 Description As described in #373, in .Net 6.0, there is a race condition where the `JSRuntime` will become unavailable before a component's `Dispose` is able to be called (may take upwards of 60 seconds). As a result, Blazor will throw a `JSDisconnectedException` on each subsequent call to `JSRuntime.InvokeVoidAsync`. The fix is to wrap the calls in `Dispose` to catch `JSDisconnectedException` and set `IsJSRuntimeAvailable` to `false`. Because `JSRuntime.InvokeVoidAsync` is in fact async, the code must `await` the result in order to catch exceptions. This pattern of calling into the runtime in `Dispose` is in many components so a wrapper was created to handle the common boilerplate code needed to wrap the component specific functionality. The improvement is most notable in the DataGrid component which calls the runtime once per column, which may trigger 4-5 exceptions being thrown per column! After this fix the first exceptions are caught and further exceptions prevented. This change in behavior is only observed in .Net 6.0, so as part of this fix a new Target was enabled and the associated changes were made. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 18:17:29 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#2154