Skip to content

Conversation

@ScarletKuro
Copy link
Member

@ScarletKuro ScarletKuro commented Oct 12, 2024

Description

Add CancellationTokenSource as was done for PopoverService.

The logic is as follows:

It was reported in #3963:

Blazor will call DisposeAsync while OnAfterRenderAsync is still executing. Apparently, this is by design, and when it occurs with a MudPopover component, it results in the handler being detached before it is reinitialized, leaving the JS objects in the browser.

If this happens, DisposeAsync will cancel the token. Even if OnAfterRenderAsync inadvertently calls our SubscribeAsync, the JS call will not be made because the CancellationTokenSource has been canceled (and disposed) by that time. Our InvokeAsyncWithErrorHandling handles both TaskCanceledException and ObjectDisposedException, when the the JS call fails nothing will happen. We do not concern ourselves with the swallowed exceptions from InvokeAsyncWithErrorHandling, as if the service is disposed, it is unusable anyway.

How Has This Been Tested?

Existing tests.

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@github-actions github-actions bot added enhancement Request for adding a new feature or enhancing existing functionality (not fixing a defect) PR: needs review labels Oct 12, 2024
@codecov
Copy link

codecov bot commented Oct 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.95%. Comparing base (28bc599) to head (c729148).
Report is 550 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #9990      +/-   ##
==========================================
+ Coverage   89.82%   90.95%   +1.12%     
==========================================
  Files         412      407       -5     
  Lines       11878    12588     +710     
  Branches     2364     2449      +85     
==========================================
+ Hits        10670    11449     +779     
+ Misses        681      583      -98     
- Partials      527      556      +29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for adding a new feature or enhancing existing functionality (not fixing a defect)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant