-
-
Notifications
You must be signed in to change notification settings - Fork 149
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(router): prevent multiple navigation at the same time #1895
Conversation
When a user clicks quickly from one page to another, the content can be duplicated close aurelia#1860
β¦router-dup-content-1860
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1895 +/- ##
==========================================
+ Coverage 88.37% 88.46% +0.09%
==========================================
Files 260 260
Lines 22847 22862 +15
Branches 5300 5301 +1
==========================================
+ Hits 20190 20226 +36
+ Misses 2657 2636 -21 β View full report in Codecov by Sentry. |
@aegenet , thanks for the PR. It seems the fix does work, though not always. Sometimes the e2e tests passed, and sometimes it failed. When some of the e2e tests failed, I can see this test result: That test result means there's something that pulls back the URL from await Promise.all([
page.waitForURL(`${baseURL}/pages/two-route`),
page.click('#page-two-link'),
]);
expect(page.url()).toBe(`${baseURL}/pages/two-route`); // <<<<<<< fails here I've checked the fix, it seems ok, so I'm not sure what could be the reason. cc @jwx |
When running locally, without the commits from master which has the changes at #1900, I also experienced the same failure, even though it's really rare. I'm not sure whether this is a playwright thing. |
@bigopon I remember there was an issue with the unit test. I think it's the same issue... and yes, it's the same: Playwright doesn't wait for the end of the navigation, so we need to wait for the end of all navigation before navigating to the last requested page. |
@aegenet thanks for checking that.
Can this actually affect the test? Once the url has been changed to |
Yes, I think, because we do a lot of navigation (page-one-link, await Promise.all([
page.waitForURL(`${baseURL}/pages/two-route`),
page.click('#page-two-link'),
]); The: page.waitForURL(`${baseURL}/pages/two-route`) can be swallowed by the previous loop "click" At the moment, I can't reproduce the issue anymore with my last commit. |
That sounds like inside a navigation the URL would be updated somehow, I'm not sure on this, but the fix isn't doing any related to that behavior so I think it's ok. Thanks @aegenet. |
Nice work, thanks @aegenet |
If you wanna test this out, our dev version should be on npm in about 15 mins @aegenet |
It's ok with the dev version: https://gist.dumber.app/?gist=93e7586ed697b010ed48517e7ad3c423 No more 'clone wars', thanks for your review and involvement. |
2.0.0-beta.12 (2024-03-02) **BREAKING CHANGE:** * **enhance:** call app tasks with `.enhance` API, return app root instead of controller (#1916) ([4d522b2](4d522b2)) * **au-compose:** always create host for non custom element composition (#1906) ([8a28e0a](8a28e0a)) **Features:** * **au-compose:** ability to compose string as element name (#1913) ([06aa113](06aa113)) **Bug Fixes:** * **router:** prevent multiple navigation at the same time (#1895) ([deed11e](deed11e)) * **router:** properly handle false in conditional router hooks (#1900) ([a671463](a671463)) * **di:** dont jit register resources ([8ffde34](8ffde34)) * **di:** new instance resolver (#1909) ([efe208c](efe208c)) * **runtime:** tweak typings of injectable token ([89f76eb](89f76eb)) **Refactorings:** * **runtime:** delay overriding array prototypes (#1914) ([d8be144](d8be144)) * **router:** use resolve ([89f76eb](89f76eb)) * **runtime:** better type inferrence for injectable token ([89f76eb](89f76eb)) * **di:** simplify container has, cleanup router ([89f76eb](89f76eb)) **Docs:** * **docs:** add JS examples using resolve for IHttpClient (#1907) ([d57c1f1](d57c1f1)) * **doc:** remove define hook from documentation (#1903) ([f684141](f684141))
Thank you too @aegenet for the work and the confirmation π |
Pull Request
π Description
When a user clicks quickly from one page to another, the content can be duplicated.
π« Issues
Resolves #1860.
π©βπ» Reviewer Notes
I prevent multiple navigations from occurring simultaneously and store the most recent one. This ensures that users don't find it odd to end up on their last desired page.
I was delayed in creating this PR because I noticed another issue with the error handling in @aurelia/router. However, it requires a separate issue/PR, as it's not just linked to this current issue.
π Test Plan
β Next Steps