Add better disposal handling after sending cleanup message to client. - #335
Add better disposal handling after sending cleanup message to client.#335MayaKirova wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates BaseRendererControl (the core base type for Ignite UI Blazor wrapper components) to make JS-bound cleanup more deterministic by adding an async disposal path and awaiting the interop cleanup message when Blazor chooses async disposal.
Changes:
- Implement
IAsyncDisposableonBaseRendererControland addDisposeAsync()to allow awaited cleanup. - Replace the synchronous cleanup sender with an async
TrySendCleanupAsync()that awaitsSendMessageImmediate(...)and swallows common teardown exceptions. - Adjust
Dispose(bool)to trigger cleanup via the new async helper (fire-and-forget) while continuing to support the existingIDisposablepattern.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Um, was going to ask, but found it in the docs right away:
So wouldn't the change be more of a conversion |
damyanpetev
left a comment
There was a problem hiding this comment.
Overall, LGTM, though I hope we can replace the cleanup message with a module dispose per modern practices soon enough.
The only bit of concern I have is if we should be marking this as a breaking change since the components no longer implement IDisposable and neither version of keeping it very clean and would rather not. Should be improbable manual use, since both the ASP.NET framework and test (bUnit) require users to do manual disposal; Still on the table tho.
Description
Make BaseRendererControl disposal deterministic and safe by implementing IAsyncDisposable alongside the existing IDisposable, and stop discarding the Task returned by the interop cleanup send.
Motivation / Context
Before this change, BaseRendererControl.Dispose(bool) called an async Task SendMessageImmediate(...) synchronously and discarded the returned Task, and the type implemented only IDisposable
Blazor’s guidance for components that perform asynchronous cleanup is to implement IAsyncDisposable: https://learn.microsoft.com/en-us/aspnet/core/blazor/components/component-disposal?view=aspnetcore-10.0&source=recommendations#asynchronous-iasyncdisposable
Type of Change (check all that apply):
Component(s) / Area(s) Affected:
All
How Has This Been Tested?
Test Configuration:
Screenshots / Recordings
Checklist:
README.MDCHANGELOG.MDupdates for newly added functionalityCloses #334