-
Notifications
You must be signed in to change notification settings - Fork 10.3k
.NET 6 Blazor server app not Disposing razor pages on browser tab close #39370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I studied problem further and it looks like problem appear in Vivaldi and Firefox but not in Google Chrome. So it's somehow browser issue. |
Hello @jeffraska thanks for contacting us. Blazor server disconnects the circuit based on the page unload event. aspnetcore/src/Components/Web.JS/src/Boot.Server.ts Lines 68 to 80 in e973236
Hmm I see, thanks for pointing that out. While Vivaldi isn't a supported browser, Firefox is. I have a feeling this may be a Firefox browser quirk to do with when/if the |
Hmm based on the usage notes for We may want to consider updating this to utilize the |
Our notification mechanism is a best effort not a guaranteed outcome, since the browser doesn't guarantee that the event is fired. Even in that case, this is a "performance" optimization to eagerly terminate the circuit when we know it won't be used any longer. In this scenario dispose gets called after around 3 minutes (by default) when we detect the connection has been lost and the client doesn't re-connect as part of disposing the entire circuit. |
Created a separate issue #39409 to track the suggestions from @TanayParikh |
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes. See our Issue Management Policies for more information. |
Is there an existing issue for this?
Describe the bug
When IDisposable is implemented in razor page and browser tab is closed by user, the Dispose method is called after few minutes and not immediately after tab close.
The very first thing I'd mention is that disposing of razor pages worked correctly in .NET 5 so apparently it's a bug in .NET 6 (or ASP.NET Core Runtime). Problem started to appear after I've upgraded my project to .NET 6.
This problem was discused previously in https://github.com/dotnet/aspnetcore/issues/38147 but solution in answer does not solve this problem - .NET knows about tab being closed but just do not call Dispose.
Expected Behavior
When browser tab is closed .NET should dispose all razor pages that existed in this session.
Steps To Reproduce
builder.Services.Configure<HubOptions>(O => O.AddFilter<HubFilter>());
and set breakpoint in OnDisconnectedAsyncExceptions (if any)
No response
.NET Version
6.0.101
Anything else?
No response
The text was updated successfully, but these errors were encountered: