Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide more information in error #55107

Open
istoyneva opened this issue Apr 12, 2024 · 11 comments
Open

Provide more information in error #55107

istoyneva opened this issue Apr 12, 2024 · 11 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-observability Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue Pillar: Dev Experience
Milestone

Comments

@istoyneva
Copy link

This error is cropping randomly. Adding more info about the "logicalElement" argument that could not be processed would go a long way:

throw new Error('Not a valid logical element');

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Apr 12, 2024
@javiercn
Copy link
Member

@istoyneva thanks for contacting us.

Do you have a minimal repro as a public github repository that we could take a look at? Is your app modifying the DOM via JS (though a library or JS interop)?

@javiercn javiercn added the Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue label Apr 16, 2024
@dotnet-policy-service dotnet-policy-service bot added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Apr 16, 2024
@istoyneva
Copy link
Author

While preparing to answer your questioonquestions, @javiercn, this is a Blazor app and I noticed that it's under aspnetcore. Do we need to move it?

@dotnet-policy-service dotnet-policy-service bot added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Apr 19, 2024
@istoyneva
Copy link
Author

istoyneva commented Apr 20, 2024

Again - this is a Blazor 8 SSR interactive.

There is more errors in the browser console. They're of the type:
image

The issue is not readily reproducible and we don't have a minimal project that experiences it.

Our code does not modify the DOM using javascript, but we use a third-party control library and I can't say what they're doing.

Could someone provide possible approaches to configure the application to capture more info around the issue? Kinda like to create dumps (client or server) or similar...

Looking at the server application log, the issue always happens after OnInitializedAsync of our main component. During OnInitializedAsync we do initialize control's binding data sources. Markup was such that the controls (in-house components plus multi-select drop downs, date pickers, grid from the third-party library) are rendered as soon as all injected properties are not null:
`
@if (_modelA is not null && _modelB is not null, ...)
{

... combination of our constrols and the third-party controls

}
`

We're trying a different condition now - one that'd disable rendering for a little longer - until after OnInitializedAsync is fully complete.

@javiercn
Copy link
Member

@istoyneva thanks for the additional details.

Our code does not modify the DOM using javascript, but we use a third-party control library and I can't say what they're doing.

Is this a public third-party control library? You can check if its loading JS on to the page, and see what that JS is doing.

One way to try and reproduce this, is by (if you are able to) trigger it once (record the steps) and then start removing elements from the page until you can no longer reproduce it.

The other thing you can do is search for the error and put a breakpoint in JS before it happens. You should see the nodes that it is complaining about in the page and see where in the app is happening in the element selector, and from them identify the problematic component

@javiercn javiercn added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Apr 21, 2024
@istoyneva
Copy link
Author

Is it possible to suggest where to set the breakpoint?

The issue is always gone on a re-try, so even if we stumble on it, by the time we set the breakpoint and refresh, it'll be gone

@dotnet-policy-service dotnet-policy-service bot added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Apr 22, 2024
@mkArtakMSFT mkArtakMSFT added enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-observability Pillar: Dev Experience and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Apr 22, 2024
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Apr 22, 2024
@istoyneva
Copy link
Author

Here's what the error call stack is:
image

It's blazor.web.js and the error context is entirely dependent on the data received - there's not much I can get out of the javascript. Logging/tracing in the directly affected methods is also not helpful or not existing at all.

Is there a way to enable the debug-level logging visible in Microsoft's code? For example the anonymous frame from the screenshot contains _ths.logger.log(Ft.Debug, ...)

r.on("JS.RenderBatch", (async(e,t)=>{
                    var n, o;
                    this._logger.log(Ft.Debug, `Received render batch with id ${e} and ${t.byteLength} bytes.`),
                    await this._renderQueue.processBatch(e, t, this._connection),
                    null === (o = (n = this._componentManager).onAfterRenderBatch) || void 0 === o || o.call(n, On.Server)
                }

@istoyneva
Copy link
Author

Some progress - I was able to capture (chrome .HAR file) the web sockets communication that preceded a similar error.
I also saved the then-copy of blazor.web.js
Is there a way to deserialize the websockets message(s) into something usable that I can feed into the js file and simulate the error occuring?

@istoyneva
Copy link
Author

I was lucky to break and step through javascript while the error was occurring.

I then re-traced the same websocket frame being applied when the error wasn't present. In both cases it's the same URL that's visited in the browser. Please see the captures.

This looks like some sort of a timing issue, Any clues as to how to correct it?

Here's the javascript debugger state when the error is not present. This is a little earlier in the sack, actual error frame state is also shown below:
image

Here's the equivalent state when the error is present:
image

Here's the state at the error site (error not present):
image
... with some additional examination of the object at site:
image

Error site with error present:
image

Markup state at the time of error NOT present:
image

... same, but with the error present:
image

This is the source code - the culprit comment placeholder seems to be the Routes component outlet:
image

I can see the bl-root is applied here, in blazor.web.js:
image

This is our Routes component:
image
image
image
image

@istoyneva
Copy link
Author

@javiercn, a lot of clues above. Can you please comment?

@istoyneva
Copy link
Author

istoyneva commented Apr 29, 2024

Here's the cause of the immediate issue inside blazor.web.js. It's important to mention that the Blazor page is running in an iframe (parent is the iframe host):
image
"e" is the comment placeholder that is bi-root before batch #3 is applied:
image

Here's a rudimentary fix that illustrates the issue - instanceof Comment is failing, but comparison to Comment's object type as a string allows the processing to complete:
image
Same fix had to be placed everywhere where instanceof Comment was used.

@mkArtakMSFT
Copy link
Member

@javiercn what do you think about the proposed change above? Will we accept it?
@istoyneva will you be open to sending a PR with the proposed change you had above?

GStoynev added a commit to GStoynev/aspnetcore that referenced this issue Jun 20, 2024
…s (and potentially other HTML elements) in the frame fail the instanceof test because they're instances of frame's parent's Comment.

Replacing instanceof with this prototype check fixes the issue.

Issue is documented here: dotnet#55107
GStoynev added a commit to GStoynev/aspnetcore that referenced this issue Jun 21, 2024
…s (and potentially other HTML elements) in the frame fail the instanceof test because they're instances of frame's parent's Comment.

Replacing instanceof with this prototype check fixes the issue.

Issue is documented here: dotnet#55107
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-observability Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue Pillar: Dev Experience
Projects
None yet
Development

No branches or pull requests

3 participants