Open ArneCools opened 12 months ago
hi
Can you upload your test project to GitHub? Thanks
https://github.com/ArneCools/abp_blazor_tiered_bug
This is the page you need to go to, to test: https://github.com/ArneCools/abp_blazor_tiered_bug/blob/main/src/MyProject.Blazor/Pages/MyAuthorizedPage.razor
hi
I keep refreshing the page, but unfortunately, I can't reproduce it.
After refreshing multiple times (using the browser refresh button or ctrl+R) I get this:
You can also see the administration button is gone.
Yes, I tried many times, but no luck.
Very strange. I get this error on my main project too. I even get the bug on our production server.
On production we get this error because there are some slower running api calls. After the call fails ( because of a TaskCanceledException after closing session) the error occurs. I managed to do a workaround by rethrowing the exception if the innerexception is TaskCanceledException. Otherwise de exception is caught, translated strings are 'rendered', and cache gets corrupt.
I'll try to do a screen capture of the steps reproduce as soon as I can
Is the problem solved?
Is there an existing issue for this?
Description
There seems to be a race-condition with the blazor server cache. When refrshing the page, the previous sessions is still rendered and loaded. Normally that's not an issue I think. But when you have 'translated' strings in your UI, that are rendered after a delay. For example an api-call (or simply using Task.Delay(5000) in OnInitializedAsync. The translation method (@L["LongWelcomeMessage"]) is rendered and called after the slow task has ran. ABP thinks that the cache is too old, so tries to get a new version. Because the blazor session is invalid, the back-end returns a new config with empty roles. That cache is saved. Meanwhile, you are on a new Blazor (signalR) session. After refreshing again, the new (corrupt) cache is used. So the UI thinks you are not authenticated correctly anymore. You stay logged in, but you have no roles & permissions. It only works again after waiting a while and refreshing until the cache is refreshed.
Reproduction Steps
I tested in a fresh project.
@if (_test) {
}
@code {
}