-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
@javiercn The current implementation (dotnet 10 preview 6) of SupplyParameterFromPersistentComponentState is removing the parameter from ParameterView if you enumerate it.
This feature is intended for when a blazor app reconnects and I strongly suspect your implementation is removing the entry from HybridCache immediately to avoid the cache memory having dirty entries that are no longer needed.
However if any code merely enumerates ParameterView (see my example) it will break the current implementation.
Expected Behavior
You cannot immediately remove the value due to enumeration of ParameterView. This breaks the implementation and would be an extremely confusing bug to diagnose.
Alternatives would include:
- Checking and cleaning up any old cache entries later in the lifecycle.
- Have some short delay until the entry is removed from the cache, or don't remove it (let it be purged based on policy).
- Only remove from cache if ParameterView is enumerated from the base class (you could have some internal flag you set from the base class before enumerating).
I am sure you will think of other even better options.
Steps To Reproduce
To repo, use the feature, then override SetParametersAsync as shown below:
public override Task SetParametersAsync(ParameterView parameters)
{
// SupplyParameterFromPersistentComponentState parameter exists here
foreach (var parameter in parameters)
{
Console.WriteLine(parameter.Name + " " + parameter.Value);
}
// SupplyParameterFromPersistentComponentState is now gone/NULL (not printed)
foreach (var parameter in parameters)
{
Console.WriteLine(parameter.Name + " " + parameter.Value);
}
return base.SetParametersAsync(parameters);
}
You can see that merely enumerating ParameterView would break the implementation. With this code above, the persisted value is no longer loaded (and we are back to dotnet 9 behaviour).
Exceptions (if any)
No response
.NET Version
.NET SDK: Version: 10.0.100-preview.6.25358.103 Commit: 75972a5ba7 Workload version: 10.0.100-manifests.b6c7f53e MSBuild version: 17.15.0-preview-25358-103+75972a5ba
Anything else?
@javiercn Let me know if you need further info.