Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Javascript error: Invalid blocker state transition #20404

Closed
jcgueriaud1 opened this issue Nov 4, 2024 · 8 comments · Fixed by #20446
Closed

Javascript error: Invalid blocker state transition #20404

jcgueriaud1 opened this issue Nov 4, 2024 · 8 comments · Fixed by #20446

Comments

@jcgueriaud1
Copy link
Contributor

jcgueriaud1 commented Nov 4, 2024

Description of the bug

When I'm navigating in my Vaadin application I have some javascript errors.

Uncaught (in promise) Error: Invalid blocker state transition: unblocked -> proceeding

image

image

Expected behavior

A javascript error should not appear in a normal case of usage.

Minimal reproducible example

Create a Vaadin application with two views in a menu, clicks multiple times on the menu.

I think the error appears when you click on the menu when the application is already navigating so if the view is really fast to load you need to click fast.

Versions

  • Vaadin / Flow version: 24.5.2
@jcgueriaud1
Copy link
Contributor Author

@mshabarov
Copy link
Contributor

This looks like a misconfiguration or misusing of React's blocker function in Flow.tsx (ReactRouter/Flow integration).

@Lodin
Copy link
Contributor

Lodin commented Nov 6, 2024

To me, this error looks like connected to the useBlocker hook. My first guess is that it somehow called multiple time that interrupts state change inside the blocker. So, it probably requires some debouncing 🤔

@mshabarov
Copy link
Contributor

To me, this error looks like connected to the useBlocker hook

Exactly, this was what I meant.

@mcollovati
Copy link
Collaborator

Maybe a check is missing here in the serverConnected callback defintion

containerRef.current.serverConnected = (cancel) => {
if (cancel) {
blocker.reset();
blockingPromise.resolve();
} else {
blocker.proceed();
blockingPromise.resolve();
}
}

@caalador caalador self-assigned this Nov 7, 2024
@caalador
Copy link
Contributor

caalador commented Nov 8, 2024

I guess the main issue here is that the sample layout uses <SideNav onNavigate={({ path }) => navigate(path!)} location={location}> which directly calls react navigate so it doesn't go to the queued navigation Flow uses. Doing a server side navigate I can not get the exception to happen, but can easily be gotten on a slow 4g network with the client sideNav.

caalador added a commit that referenced this issue Nov 12, 2024
Fix issue where a slow connection
and fast `navigate` calls throws
exception due to faulty blocker
state change.

Fixes #20404
@caalador caalador moved this to 🔎Iteration reviews in Vaadin Flow ongoing work (Vaadin 10+) Nov 13, 2024
@caalador caalador moved this from 🔎Iteration reviews to ⚒️ In progress in Vaadin Flow ongoing work (Vaadin 10+) Nov 13, 2024
mshabarov added a commit that referenced this issue 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 <61410877+mshabarov@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from 🔖 Normal Priority (P2) to ✅ Closed in Vaadin Flow bugs & maintenance (Vaadin 10+) Nov 25, 2024
@github-project-automation github-project-automation bot moved this from 🔎Iteration reviews to Done in Vaadin Flow ongoing work (Vaadin 10+) Nov 25, 2024
vaadin-bot pushed a commit that referenced this issue 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 <61410877+mshabarov@users.noreply.github.com>
vaadin-bot pushed a commit that referenced this issue 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 <61410877+mshabarov@users.noreply.github.com>
vaadin-bot pushed a commit that referenced this issue 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 <61410877+mshabarov@users.noreply.github.com>
vaadin-bot added a commit that referenced this issue 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 <mikael.grankvist@vaadin.com>
Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
vaadin-bot added a commit that referenced this issue 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 <mikael.grankvist@vaadin.com>
Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
caalador pushed a commit that referenced this issue Nov 25, 2024
Fix issue where a slow connection
and fast `navigate` calls throws
exception due to faulty blocker
state change.

Fixes #20404
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.5.6.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.4.19.

# for free to join this conversation on GitHub. Already have an account? # to comment