Sporadic exception 'Cannot read properties of null (reading 'innerHTML')' in HtmlEditor #398

Closed
opened 2026-01-29 17:36:39 +00:00 by claunia · 2 comments
Owner

Originally created by @OndrejUzovic on GitHub (May 5, 2022).

I find the following exception in the log file of my application:

Microsoft.JSInterop.JSException: Cannot read properties of null (reading 'innerHTML')
TypeError: Cannot read properties of null (reading 'innerHTML')
    at Object.queryCommands (https://xxx.azurewebsites.net/_content/Radzen.Blazor/Radzen.Blazor.js:1129:17)
    at https://xxx.azurewebsites.net/_framework/blazor.server.js:1:3501
    at new Promise (<anonymous>)
    at kt.beginInvokeJSFromDotNet (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:3475)
    at https://xxx.azurewebsites.net/_framework/blazor.server.js:1:72001
    at Array.forEach (<anonymous>)
    at kt._invokeClientMethod (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:71987)
    at kt._processIncomingData (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:70029)
    at vt.connection.onreceive (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:64432)
    at WebSocket.o.onmessage (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:48766)
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Radzen.Blazor.RadzenHtmlEditor.UpdateCommandState()
   at Radzen.Blazor.RadzenHtmlEditor.OnFocus()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

The exception is sporadic (several occurrences per day) and unfortunately I am not able to identify an exact use-case to reproduce it.

So I would like to ask if you have any idea what could be the problem.

Originally created by @OndrejUzovic on GitHub (May 5, 2022). I find the following exception in the log file of my application: ``` Microsoft.JSInterop.JSException: Cannot read properties of null (reading 'innerHTML') TypeError: Cannot read properties of null (reading 'innerHTML') at Object.queryCommands (https://xxx.azurewebsites.net/_content/Radzen.Blazor/Radzen.Blazor.js:1129:17) at https://xxx.azurewebsites.net/_framework/blazor.server.js:1:3501 at new Promise (<anonymous>) at kt.beginInvokeJSFromDotNet (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:3475) at https://xxx.azurewebsites.net/_framework/blazor.server.js:1:72001 at Array.forEach (<anonymous>) at kt._invokeClientMethod (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:71987) at kt._processIncomingData (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:70029) at vt.connection.onreceive (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:64432) at WebSocket.o.onmessage (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:48766) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args) at Radzen.Blazor.RadzenHtmlEditor.UpdateCommandState() at Radzen.Blazor.RadzenHtmlEditor.OnFocus() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) ``` The exception is sporadic (several occurrences per day) and unfortunately I am not able to identify an exact use-case to reproduce it. So I would like to ask if you have any idea what could be the problem.
Author
Owner

@OndrejUzovic commented on GitHub (Jun 20, 2022):

One scenario when the exception sporadically occurs is in a dialog with RadzenTabs:

  1. Open the dialog - the first Tab which contains RadzenHtmlEditor is displayed (RadzenHtmlEditor contains a text) .
  2. Click to another tab.
  3. Close the dialog.
@OndrejUzovic commented on GitHub (Jun 20, 2022): One scenario when the exception **sporadically** occurs is in a dialog with RadzenTabs: 1. Open the dialog - the first Tab which contains RadzenHtmlEditor is displayed (RadzenHtmlEditor contains a text) . 2. Click to another tab. 3. Close the dialog.
Author
Owner

@jafin commented on GitHub (Jul 5, 2024):

Just started hitting this same issue as well.
With RadzenHtmlEditor in Radzen.Blazor v4.33.3

  • Occurs intermittently, not always

If I can detect any more concrete steps I'll update my post.

Microsoft.JSInterop.JSException: Cannot read properties of null (reading 'innerHTML')
TypeError: Cannot read properties of null (reading 'innerHTML')
    at Object.innerHTML (https://localhost:7134/_content/Radzen.Blazor/Radzen.Blazor.js:1692:18)
    at https://localhost:7134/_framework/blazor.web.js:1:3244
    at new Promise (<anonymous>)
    at y.beginInvokeJSFromDotNet (https://localhost:7134/_framework/blazor.web.js:1:3201)
    at gn._invokeClientMethod (https://localhost:7134/_framework/blazor.web.js:1:62841)
    at gn._processIncomingData (https://localhost:7134/_framework/blazor.web.js:1:60316)
    at connection.onreceive (https://localhost:7134/_framework/blazor.web.js:1:53957)
    at i.onmessage (https://localhost:7134/_framework/blazor.web.js:1:82102)
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
   at Radzen.Blazor.RadzenHtmlEditor.OnAfterRenderAsync(Boolean firstRender)

In blazor.js
image

I'm not sure if changing this to ref?.innerHTML has any side effects for callers

@jafin commented on GitHub (Jul 5, 2024): Just started hitting this same issue as well. With `RadzenHtmlEditor` in `Radzen.Blazor v4.33.3` - Occurs intermittently, not always If I can detect any more concrete steps I'll update my post. ```text Microsoft.JSInterop.JSException: Cannot read properties of null (reading 'innerHTML') TypeError: Cannot read properties of null (reading 'innerHTML') at Object.innerHTML (https://localhost:7134/_content/Radzen.Blazor/Radzen.Blazor.js:1692:18) at https://localhost:7134/_framework/blazor.web.js:1:3244 at new Promise (<anonymous>) at y.beginInvokeJSFromDotNet (https://localhost:7134/_framework/blazor.web.js:1:3201) at gn._invokeClientMethod (https://localhost:7134/_framework/blazor.web.js:1:62841) at gn._processIncomingData (https://localhost:7134/_framework/blazor.web.js:1:60316) at connection.onreceive (https://localhost:7134/_framework/blazor.web.js:1:53957) at i.onmessage (https://localhost:7134/_framework/blazor.web.js:1:82102) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args) at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args) at Radzen.Blazor.RadzenHtmlEditor.OnAfterRenderAsync(Boolean firstRender) ``` In blazor.js ![image](https://github.com/radzenhq/radzen-blazor/assets/127927/e1a434ef-10a1-4a1e-8662-6254ed7114de) I'm not sure if changing this to `ref?.innerHTML` has any side effects for callers
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#398