-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Disconnect circuit on beforeunload
event
#23224
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
Conversation
059f0e3
to
c6d4a2b
Compare
@captainsafia can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
I assume you've done due diligence on testing it on various situations, so signing-off.
Yes, if the user accepts the "Do you want to navigate away from this page?" prompt that the browser provides. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Glad there was such a clean fix here!
Assuming there are no known drawbacks, this seems like a very strong patch candidate.
ecbc0fe
to
6efa8b8
Compare
6efa8b8
to
cc5d295
Compare
Made some modifications after testing a few more scenarios. Re-requesting reviews for this. We register the same event handler on both the |
What motivated this change? It would be good to keep a record for the future |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, interested in knowing the reason for subscribing to both events
Chrome won't fire the event if the user hasn't interact with the page. This ends up happening in our CI tests because we call Firefox allows users to set a |
@mkArtakMSFT Can you merge this? |
* Disconnect circuit on `beforeunload` event (#23224) * Add delay before showing Reconnection UI (#24137) * Add CSS delay before showing Reconnection UI * rebuild yet again to try and get past the conflict * Move reconnection delay mechanism into framework code (#24566) Co-authored-by: SQL-MisterMagoo <[email protected]> Co-authored-by: Steve Sanderson <[email protected]>
Just curious but... what sort of QA/unit-testing does a patch like this go through before it's unleashed on the public as a release? This appears to have caused a fairly significant/fundamental issue with the NavigationManager opening links and it seems like this should have shown up in some simple tests. I'm trying to make a case for Blazor at work and things like this really scare the business away from it. Can there be a bit more diligence before things like this get pushed to the production release please? |
@alexclarkmusa thank you for your feedback. Patches have a high bar for compatibility and go through a validation process before being released. We had tests that covered normal page navigations, but unfortunately we had a blind spot in our test \ scenario coverage for this particular use case. We will be reverting the patch shortly and we are filling the test hole. We are committed to making sure you're able to confidently pick up new patch releases without the risk of regression and we will be much more cautious making changes of this kind going forward. |
Closes #19050.
In the issue above, the user originally reported that they would see our reconnect modal when navigating away from Firefox. They pointed at inconsistent behavior through browser versions. They'll always see the reconnect modal on Firefox but only on a few version of Chrome.
While debugging this, I realized that this is because our clean-up handler that is registered to the
unload
event is never invoked in Chrome.The
unload
event is not emitted and, consequently, the async request sent to/disconnect
vianavigator.sendBeacon
is never emitted.It turns out that Chrome is discouraging developers from using the
unload
event in favor of its new page navigation APIs (ref). Chrome made some changes to theunload
andbeforeunload
APIs around Chrome 80, I suspect that this is when the regression happened.I tried triggered the clean-up on a few other events (like
pagehide
andvisibilitychange
) but ultimately settled onbeforeunload
because:pagehide
event isn't triggered all the time in some browsers depending on when the subsequent page is loadedvisibilitychange
is triggered for too many scenarios