-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Blazor server-side] Improved logging for JS interop #12182
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
Conversation
eventArgsJson = element.GetString(); | ||
} | ||
} | ||
var _ = EnsureCircuitHost().DispatchEvent(eventDescriptor, eventArgsJson); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a way to differentiate between what it is essentially well-formed bad input (like an event for a non-existing handler) and exceptions in user code (Exceptions thrown inside developer's event handling code).
@rynowak Javier and I discussed this today and quite a lot of the shape of it is going to change. The existing JS interop contract makes it hard to understand whether things succeeded or failed, leading to this PR duplicating various bits of the parsing logic, and some odd special-case logic on the TS side. The plan now is to change the JS interop contract to expose the specific data needed for a platform implementation to log it sensibly. So you might want to hold off on reviewing it for now. |
I spoke with Steve and we are doing some adjustments.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really interested to see thoughts from @SteveSandersonMS - I see this kind of thing as a pure win - making these features first-class rather than tunneled though the same layer as app code means that we can have them break the rules if necessary. I know this is something we've debated in the past 😆
await Renderer.Dispatcher.InvokeAsync(() => | ||
{ | ||
SetCurrentCircuitHost(this); | ||
return RendererRegistryEventDispatcher.DispatchEvent(eventDescriptor, eventArgsJson); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same deal. There's no more need for a magic static in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can dispatch the event directly to the renderer, we would need to have a method to interpret the event args. https://github.com/aspnet/AspNetCore/blob/a784f4575b738ec5b7c6f5cfff2b1fee10de5118/src/Components/Web/src/RendererRegistryEventDispatcher.cs#L24-L25
14712df
to
f80094b
Compare
Apply suggestions from Steve Co-Authored-By: Steve Sanderson <[email protected]>
🆙 📅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! This looks really good!
The commits are included in this PR are included in #12250 which will be merged with the rest of the dependency updates, so closing this PR in favor of that. |
Original logging PR + structural changes to support routing events and .NET interop through specific paths separate from JS interop.
Associated PR with JSInterop changes to support this PR dotnet/extensions#2043