Skip to content
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

fix: multiple fast navigate calls #20446

Merged
merged 8 commits into from
Nov 25, 2024

Conversation

caalador
Copy link
Contributor

Fix issue where a slow connection
and fast navigate calls throws
exception due to faulty blocker
state change.

Fixes #20404

Fix issue where a slow connection
and fast `navigate` calls throws
exception due to faulty blocker
state change.

Fixes #20404
Copy link

github-actions bot commented Nov 12, 2024

Test Results

1 158 files  ±0  1 158 suites  ±0   1h 34m 15s ⏱️ - 1m 38s
7 513 tests ±0  7 460 ✅ ±0  53 💤 ±0  0 ❌ ±0 
7 887 runs  +8  7 824 ✅ +8  63 💤 ±0  0 ❌ ±0 

Results for commit e60dba1. ± Comparison against base commit d418c0e.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@mshabarov mshabarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch looks good.
Smoke tested it, couldn't spot anything weird.
However, I couldn't reproduce the original issue.

Another pair of eyes would be beneficial.

@caalador
Copy link
Contributor Author

Easiest way to replicate original issue is to have a hilla layout and 2 flow layouts, setting the network throttling to slow 4g , then navigating to a flow view from a flow view through the layout menu and clicking 2 times on the menu item.

Copy link
Contributor

@mshabarov mshabarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked with @platosha on Friday, this patch slightly changes how navigation works: with a slow network, when you first time click on the menu link and immediately click on the second one, the application will ignore the second navigation and basically all other navigations until the first one completes.
Maybe it's better to queue these navigations and apply the latest in the end. Flow navigation works like this IIRC.
@platosha promised to see how we can do it.
@caalador do you think it's better to queue like I described?

@caalador
Copy link
Contributor Author

We could push the navigate to queuedNavigate instead of canceling the navigation. I think we have enough information to do that.

The issue is that when the programmer uses react-router navigate() directly when on a Flow view it bypasses all the features for navgation we have except for the blocker and this will start multiple blockers at the same time setting the blocker state multiple times for the same instance as the latter one overwrites the previous one without checking if it is blocking already or not.

@mshabarov mshabarov self-requested a review November 18, 2024 12:46
Copy link
Contributor

@mshabarov mshabarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tip, the exception has eventually appeared for me and after the latest changes I don't see it anymore and the multiple navigations are queued and handled as I expected - the last click wins in the end.

I think we can try adding a test that simulates the same steps, I wonder if these codes works:

public class UseBlockerIT extends ChromeDeviceTest {

    @Test
    public void test() {
        ChromeDriver driver = (ChromeDriver) getDriver();
        DevTools devTools = driver.getDevTools();
        devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));
        devTools.send(Network.emulateNetworkConditions(
                false, // offline
                100,   // latency (ms)
                750000, // download through (bits per second)
                250000, // upload throughput (bits per second)
                Optional.of(ConnectionType.CELLULAR4G), // connection type
                Optional.empty(),
                Optional.empty(),
                Optional.empty()
        ));
        // open a page
        // click twice
        // check for errors
        // check the latest navigation
    }
}

If Flow repo is not a suitable place for it, could we add it to platform test module?

caalador and others added 2 commits November 25, 2024 11:06
Add test view for manual testing.
Test script doesn't fail on double click.
@caalador
Copy link
Contributor Author

Couldn't get the test to fail for multiple fasts clicks when clicking programmatically.
Setting network_conditions before open made the test really slow indicating that it probably does work, but it doesn't help with the test. Adding either a timeout 0 or animation frame makes the second click throw due to undefined so it is too late.

mshabarov
mshabarov previously approved these changes Nov 25, 2024
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.26.0</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worrying about maintenance for this: future Chrome updates can be incompatible with the ChromeDriver, so we have to bump this version all the time.
If the test always passes, maybe we can disable it, so it will show case the failing scenario, but won't run in CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed test and added doc on the view class.

mshabarov
mshabarov previously approved these changes Nov 25, 2024
@mshabarov mshabarov enabled auto-merge (squash) November 25, 2024 10:04
Copy link

sonarcloud bot commented Nov 25, 2024

@mshabarov mshabarov merged commit 056c126 into main Nov 25, 2024
25 of 26 checks passed
@mshabarov mshabarov deleted the issues/20404-multiple-navigate-break-blocker branch November 25, 2024 11:06
vaadin-bot pushed a commit that referenced this pull request Nov 25, 2024
* fix: multiple fast navigate calls

Fix issue where a slow connection
and fast `navigate` calls throws
exception due to faulty blocker
state change.

Fixes #20404

* Queue new navigations during ongoing navigation.

* fix blocker nav for basepath

Add test view for manual testing.
Test script doesn't fail on double click.

* Remove test class and selenium dependency.

---------

Co-authored-by: Mikhail Shabarov <[email protected]>
vaadin-bot pushed a commit that referenced this pull request Nov 25, 2024
* fix: multiple fast navigate calls

Fix issue where a slow connection
and fast `navigate` calls throws
exception due to faulty blocker
state change.

Fixes #20404

* Queue new navigations during ongoing navigation.

* fix blocker nav for basepath

Add test view for manual testing.
Test script doesn't fail on double click.

* Remove test class and selenium dependency.

---------

Co-authored-by: Mikhail Shabarov <[email protected]>
vaadin-bot pushed a commit that referenced this pull request Nov 25, 2024
* fix: multiple fast navigate calls

Fix issue where a slow connection
and fast `navigate` calls throws
exception due to faulty blocker
state change.

Fixes #20404

* Queue new navigations during ongoing navigation.

* fix blocker nav for basepath

Add test view for manual testing.
Test script doesn't fail on double click.

* Remove test class and selenium dependency.

---------

Co-authored-by: Mikhail Shabarov <[email protected]>
vaadin-bot added a commit that referenced this pull request Nov 25, 2024
* fix: multiple fast navigate calls

Fix issue where a slow connection
and fast `navigate` calls throws
exception due to faulty blocker
state change.

Fixes #20404

* Queue new navigations during ongoing navigation.

* fix blocker nav for basepath

Add test view for manual testing.
Test script doesn't fail on double click.

* Remove test class and selenium dependency.

---------

Co-authored-by: caalador <[email protected]>
Co-authored-by: Mikhail Shabarov <[email protected]>
vaadin-bot added a commit that referenced this pull request Nov 25, 2024
* fix: multiple fast navigate calls

Fix issue where a slow connection
and fast `navigate` calls throws
exception due to faulty blocker
state change.

Fixes #20404

* Queue new navigations during ongoing navigation.

* fix blocker nav for basepath

Add test view for manual testing.
Test script doesn't fail on double click.

* Remove test class and selenium dependency.

---------

Co-authored-by: caalador <[email protected]>
Co-authored-by: Mikhail Shabarov <[email protected]>
caalador pushed a commit that referenced this pull request Nov 25, 2024
Fix issue where a slow connection
and fast `navigate` calls throws
exception due to faulty blocker
state change.

Fixes #20404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Javascript error: Invalid blocker state transition
3 participants