Repository navigation
Fixed race condition in the disposing of the QuickGrid - #62840
Merged
ilonatommy merged 8 commits intoJul 28, 2025
Merged
Conversation
ilonatommy
reviewed
Jul 22, 2025
ilonatommy
reviewed
Jul 22, 2025
ilonatommy
reviewed
Jul 22, 2025
Member
|
/azp run |
|
Azure Pipelines successfully started running 4 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a race condition in the QuickGrid component that could occur when the component is disposed while a JavaScript module is still being loaded. The fix adds a disposal flag to prevent JavaScript operations from executing after disposal has begun.
- Adds a
_wasDisposedboolean flag to track disposal state and prevent operations after disposal - Updates the disposal and rendering logic to handle race conditions gracefully
- Introduces comprehensive tests to verify the fix works and demonstrates the original problem
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| QuickGrid.razor.cs | Adds _wasDisposed flag and disposal race condition protection |
| GridRaceConditionTest.cs | New test class with comprehensive race condition testing |
| NotFailingQuickGrid.cs | Test helper component that uses the fixed QuickGrid implementation |
| FailingQuickGrid.cs | Test helper component that simulates the original race condition bug |
| Microsoft.AspNetCore.Components.csproj | Adds internal visibility for QuickGrid tests |
| Microsoft.AspNetCore.Components.QuickGrid.Tests.csproj | Includes shared test helpers |
Comments suppressed due to low confidence (1)
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor.cs:156
- [nitpick] The field name
_wasDisposedshould be_disposeBoolto match the variable name referenced in the PR description and test code, ensuring consistency across the codebase.
private bool _wasDisposed;
ilonatommy
approved these changes
Jul 25, 2025
ilonatommy
left a comment
Member
There was a problem hiding this comment.
Great job!
Only a few clean-up updates.
…Grid/test/GridRaceConditionTest.cs Co-authored-by: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com>
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed race condition in the disposing of the QuickGrid
Description
This pull request introduces changes to improve the disposal logic of the
QuickGridcomponent and adds new tests to ensure proper handling of race conditions during disposal. It also updates project files to include new test dependencies and internal visibility settings. Below is a summary of the most important changes:Changes:
_disposeBoolflag to theQuickGridcomponent to track its disposal state and prevent further operations if disposal is in progress.DisposeAsyncmethod to set_disposeBooltotrueand ensure proper cleanup of resources.OnAfterRenderAsyncmethod to check the_disposeBoolflag and exit early if the component is being disposed while the JavaScript module is loading.GridRaceConditionTest, to verify that theQuickGridcomponent can handle race conditions during disposal without errors. This includes simulating JavaScript interop behavior and rendering scenarios.InternalsVisibleToforMicrosoft.AspNetCore.Components.QuickGrid.Testsin theMicrosoft.AspNetCore.Components.csprojfile to allow internal access for testing purposes.Microsoft.AspNetCore.Components.QuickGrid.Tests.csprojfile to include shared test helpers and dependencies for the new tests.Fixes #47173